随笔分类 - 爬虫
摘要:1 import requests 2 from requests.exceptions import RequestException 3 from pyquery import PyQuery as pq 4 from bs4 import BeautifulSoup 5 import pymo
阅读全文
摘要:1 # 开始写爬虫前,先确定目标网页是否允许爬取相关页面 2 from urllib.robotparser import RobotFileParser 3 4 UrlRobots = 'https://book.douban.com/robots.txt' 5 6 def GetRobotsTx
阅读全文
摘要:备忘 1 import urllib.parse 2 import urllib.request 3 # 将数据使用urlencode编码处理后,再使用encoding设置为utf-8编码 4 data = bytes(urllib.parse.urlencode({"word":"hello"})
阅读全文
摘要:为了分析深圳市所有长租、短租公寓的信息,爬取了某租房公寓网站上深圳区域所有在租公寓信息,网站上租房信息共有258页,每页有20条租房信息(第258页为13条),以下记录了爬取过程以及爬取过程中遇到的问题: 爬取流程: 爬取代码: 1 import requests 2 from requests.e
阅读全文
摘要:——利用Phantomjs和PySpider就可以抓取通过JavaScript渲染的网页啦 先来解释一下框架中的代码结构: 定义一个Handler类,它继承于父类BaseHandler,里面包含三个函数:on_start()进入目标网站,返回索引页html代码并传给index_page();inde
阅读全文
摘要:在崔庆才老师的视频讲解基础上,添加了模拟登陆步骤: 1 from selenium import webdriver 2 from selenium.webdriver.common.by import By 3 from selenium.webdriver.support.wait import
阅读全文
摘要:目标url:https://book.douban.com/tag/?view=type&icn=index-sorttags-all 目的:抓取所有标签名称(tag_name),标签链接(tag_url),标签下的书籍数量(tag_book_num) 先创建一个config.py文件,设置mong
阅读全文
摘要:最近看崔庆才老师的爬虫课程,第一个实战课程是requests和正则表达式爬取猫眼电影Top100榜单。虽然理解崔老师每一步代码的实现过程,但自己敲代码的时候还是遇到了不少问题: 问题1:获取response.text时出现中文乱码的问题 问题2:通过requests.get()方法获取的网页代码与网
阅读全文
摘要:1 import requests 2 import re 3 from multiprocessing import Pool 4 from requests.exceptions import RequestException 5 import json 6 import time 7 8 9
阅读全文

浙公网安备 33010602011771号