Python 爬取斗图啦图片
斗图啦 requests BeautifulSoup4 代码 # -*- coding:utf-8 -*- # pip install requests 框架 import requests # pip install beautifulsoup4 框架 # pip install lxml 解析器 from bs4 import BeautifulSoup import os class doutuSpider(object): headers = { "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" } def get_url(self, url): data = requests.get(url, headers=self.headers) soup = BeautifulSoup(data.content, 'lxml') totals = soup.findAll("a", {"cla...