我完全不熟悉网络抓取,所以任何参考网站都会很棒。我对于如何获得实际数据有些困惑。当我打印(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)
谢谢你的网站!然而,我正在做一个家庭作业,需要使用正则表达式。这就是为什么我很难找到一个网站来解释基础知识。 – Shan
这应该有助于python https://docs.python.org/2/library/re.html 这对于一般的正则表达式http://regexone.com/ –
非常感谢! – Shan