我正在制作游戏,某种口袋妖怪可以去黑客攻击。 我的游戏必须下载设备的位置,但有一个问题。 我发现显示您的经纬度的网站,但我无法得到它。我制作了一个脚本:在Python中获取html网站的一部分
import urllib.request
response = urllib.request.urlopen('http://python.org/')
html = response.read()
print(html)
该脚本使站点代码分配给名为html的变量并将其打印出来。
(网站看起来好像是这样)
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<body style>
<div class="container">
::before
<div class="rows">
<div class="col-md-4 current-location-detail">
<table class="table">
<trbody>
<tr>
<td width="30%">Latitude </td>
<td id="latitude">50.19869</td>
</tr>
<tr>
<td>Longitude </td>
<td id="longitude">17.17034</td>
</tr>
我怎样才能得到经度和纬度使用此代码?请帮帮我。
你是什么意思的“网站的一部分”?你想阅读的HTML没有完全下载它? (这是'urlopen'的作用),还是你想从页面中提取一些数据? – Anonta
我需要纬度 –