Python 爬取周杰伦instagram

Python 爬取周杰伦instagram

整体框架

使用国内能访问的某国外 app angine 爬取Jay的 Instagram 并显示,再使用国内的 sae 访问这个网站,再爬取一次并发送到微博小号。

bs4

使用requests爬取 Instagram 时候,并没有加request header,Instagram 对 robot 还算友好,直接返回不带 js 的网页信息。通过bs4迅速定位到照片、视频信息,再用正则表达式提取到链接并下载、显示。

from bs4 import  BeautifulSoup

filepath = 'C:\Users\hndx\Desktop\ins.html'
soup = BeautifulSoup(open(filepath),'lxml')

script = soup.select('script')

print script[2]

这样script[2]就是带有Jay最新动态信息的 Unicode 字符了。

未完待续

猜你喜欢

转载自www.cnblogs.com/aubucuo/p/Jay.html