返回信息流http://www.ppdai.com/list/100007这里面的user爬不出来,我的正则是r'alt=".*?"',在线等,急求
这是一条镜像帖。来源:北邮人论坛 / python / #3555同步于 2014/10/7
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖
【急求】正则爬不出来
cm2b
2014/10/7镜像同步8 回复
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
还有一个问题,我用
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
去打开网页打不开,但是我在浏览器中输入网址就能打开
html = getHtml("http://www.ppdai.com/list/100007")
【 在 binux 的大作中提到: 】
: 为什么你会觉得用alt=".*?"能爬出来?
这个需要登录的吧?
【 在 cm2b 的大作中提到: 】
: 还有一个问题,我用
: def getHtml(url):
: page = urllib.urlopen(url)
: ...................
加个user-agent,然后
#encoding=utf-8
import requests
import re
headers = {
'user-agent': 'Mozilla/5.0'
}
url = 'http://www.ppdai.com/list/100007'
r = requests.get(url, headers=headers)
name = re.findall(ur'alt="([^"]*)"', r.text)[0]
【 在 cm2b 的大作中提到: 】
: 还有一个问题,我用
: def getHtml(url):
: page = urllib.urlopen(url)
: ...................