随笔分类 - 爬虫
摘要:# # 导入需要的爬虫库。import urllib.request# # 请求百度的连接。# file = urllib.request.urlopen('http://www.baidu.com')# # 读取返回的数据。# data = file.read()# # 将百度返回的数据写入到文件
阅读全文
摘要:# 爬虫思路:首先找到约会吧的链接地址,# 然后获取网页,从中提取出每个发消息用户的详情页,找到存放图片的详情页链接,# 根据地址爬取图片import requests,parsel# 用来获取约会吧主页的函数def get_yuehuiba_url(url,headers): # 通过reques
阅读全文
摘要:# 导入需要的包import requestsimport time,randomfrom openpyxl import Workbookimport pymysql.cursors#@ 连接数据库;# 这个是我本地上边运行的程序,用来获取代理服务器。def get_proxy(): try: P
阅读全文
摘要:# 导入requests 和 BeautifulSoupimport requestsfrom bs4 import BeautifulSoupdef download_page(url): # 定义头部,用来骗过浏览器 headers ={'User-Agent': 'Mozilla/5.0 (W
阅读全文
摘要:# 爬取豆瓣最受欢迎的250部电影,并写入Excel表格中import requests,xlwtfrom bs4 import BeautifulSoup# 请求豆瓣网站,获取网页源码def request_douban(url): try : # 请求url headers = {"User-A
阅读全文
摘要:# import requests,re,json# # 定义一个函数用来请求当当网的网页信息# def request_dangdang(url):# try:# # 使用get请求# response = requests.get(url)# # 判断返回的状态码是否为200# if respo
阅读全文

浙公网安备 33010602011771号