germey / toutiao Goto Github PK
View Code? Open in Web Editor NEWTouTiao Spider Demo
TouTiao Spider Demo
自己在存储前加了一个目录判断,程序可以正常运行,但是下载图片结果是每篇文章只有一张图片被下载存储。代码如下:
def save_images(content, page, title):
dir_path = '{0}/{1}/{2}/{3}'.format(os.getcwd(), 'images',page//20, title)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
file_path = '{0}/{1}.{2}'.format(dir_path, md5(content).hexdigest(), 'jpg')
if not os.path.exists(file_path):
with open(file_path, 'wb') as f:
f.write(content)
f.close()
执行后403 Forbidden
是猫眼更行了反扒策略吗?
求问,为什么照着您的教程敲得正则代码,在pycharm中要不就是一直运行没有结果,要不就是结果为空,我也对照了新的网页代码(猫眼电影和豆瓣),求教,是否是pycharm问题或者是什么?多谢了。
经过多次尝试使用requests
请求详情页,发现最少发生一次重定向,最多三次,重定向路径为
[http://taobao.com/group/xxxxxxx -> http://www.taobao.com/group/xxxxxxx -> https://www.taobao.com/group/xxxxxx -> https://www.taobao.com/axxxxxxxx]
这种情况导致在获取html代码的时候无法获取到最终url的代码怎么解决?所以无法正常找到想要的内容
我自己是把从 article_url
获取到的 url
中的 group/
替换成 a
就能正常访问了。
url = 'http://toutiao.com/group/6444359581934141710/'
url = url.replace('group/', 'a')
代码修正后:cnsimo/toutiao
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.