Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行成功,但没有结果 #3

Open
lihaogm opened this issue Sep 25, 2020 · 5 comments
Open

运行成功,但没有结果 #3

lihaogm opened this issue Sep 25, 2020 · 5 comments

Comments

@lihaogm
Copy link

lihaogm commented Sep 25, 2020

程序虽然运行成功,但是没有结果。
debug后,发现在正则匹配的时候没有返回结果。
items = re.findall(pattern, html) items 为空

@lihaogm lihaogm changed the title 运行成功,没有结果 运行成功,但没有结果 Sep 25, 2020
@zhishui1
Copy link

程序虽然运行成功,但是没有结果。
debug后,发现在正则匹配的时候没有返回结果。
items = re.findall(pattern, html) items 为空

看了下,猫眼的首页加了个验证码验证,所以没有获取到正确的网页源代码

@xiaomx32
Copy link

进入猫眼首页,手动验证一下,代码就可以运行了

@JacobHuangCHINA
Copy link

JacobHuangCHINA commented Jul 4, 2021

可以先手动登录猫眼网站,然后在浏览器获取自己的cookie,然后在get_one_page(url)函数中添加一个 cookie,然后在请求里添加cookie
cookies = {'cookie': '你自己的cookie'} response = requests.get(url, cookies=cookies, headers=headers)
这样就可以了,但是这样只获取了40个电影信息,没有获取到100个,具体什么原因还没有找到,找到后再更新一下

@JacobHuangCHINA
Copy link

可以先手动登录猫眼网站,然后在浏览器获取自己的cookie,然后在get_one_page(url)函数中添加一个 cookie,然后在请求里添加cookie
cookies = {'cookie': '你自己的cookie'} response = requests.get(url, cookies=cookies, headers=headers)
这样就可以了,但是这样只获取了40个电影信息,没有获取到100个,具体什么原因还没有找到,找到后再更新一下

Debug 后, 发现猫眼首页添加了反爬虫-验证拼图,所以后面的返回的是一个验证url,自然爬取不了,等学习到后面如何处理验证,再回来解答

@ddhhtt271
Copy link

今天试了一下,爬是可以爬,但好像爬了一次以后要隔一段时间才能再爬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants