Comments (5)
程序虽然运行成功,但是没有结果。
debug后,发现在正则匹配的时候没有返回结果。
items = re.findall(pattern, html)
items 为空
看了下,猫眼的首页加了个验证码验证,所以没有获取到正确的网页源代码
from maoyan.
进入猫眼首页,手动验证一下,代码就可以运行了
from maoyan.
可以先手动登录猫眼网站,然后在浏览器获取自己的cookie,然后在get_one_page(url)函数中添加一个 cookie,然后在请求里添加cookie
cookies = {'cookie': '你自己的cookie'} response = requests.get(url, cookies=cookies, headers=headers)
这样就可以了,但是这样只获取了40个电影信息,没有获取到100个,具体什么原因还没有找到,找到后再更新一下
from maoyan.
可以先手动登录猫眼网站,然后在浏览器获取自己的cookie,然后在get_one_page(url)函数中添加一个 cookie,然后在请求里添加cookie
cookies = {'cookie': '你自己的cookie'} response = requests.get(url, cookies=cookies, headers=headers)
这样就可以了,但是这样只获取了40个电影信息,没有获取到100个,具体什么原因还没有找到,找到后再更新一下
Debug 后, 发现猫眼首页添加了反爬虫-验证拼图,所以后面的返回的是一个验证url,自然爬取不了,等学习到后面如何处理验证,再回来解答
from maoyan.
今天试了一下,爬是可以爬,但好像爬了一次以后要隔一段时间才能再爬
from maoyan.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maoyan.