Sha*_*han 0 python web-scraping web
我对网络抓取完全不熟悉,所以任何参考网站都会很棒.我对如何获取实际数据感到有些困惑.当我打印(theText)时,我得到了一堆html代码(应该是正确的).我如何从中获取价值呢?我是否必须使用正则表达式来获取实际的数值数据?
def getData():
request = urllib.request.Request("http://www.weather.com/weather/5day/l/USGA0028:1:US")
response = urllib.request.urlopen(request)
the_page = response.read()
theText = the_page.decode()
print(theText)
Run Code Online (Sandbox Code Playgroud)
看看BeautifulSoup.它允许您通过ID或标签获取元素.它对基本抓取非常有用.
您可以使用响应文本(html页面)调用美味的汤,然后您可以调用bs方法
| 归档时间: |
|
| 查看次数: |
227 次 |
| 最近记录: |