07 2024 档案

摘要:Items 程序 import scrapy class DangdangItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() src = scrapy.Field() name 阅读全文
posted @ 2024-07-16 19:17 donghongchao 阅读(6) 评论(0) 推荐(0) 编辑
摘要:IPython 是一个基于 Python 的交互式计算环境,它为用户提供了一个更为强大和丰富的界面来使用Python语言。相较于标准的Python解释器,IPython提供了更多的增强功能,例如提供智能的自动补全,高亮输出,及其他特性。 如果我们安装了IPython,scrapy终端将使用IPyth 阅读全文
posted @ 2024-07-16 12:51 donghongchao 阅读(17) 评论(0) 推荐(0) 编辑
摘要:1、Scrapy Engine(引擎组件): 负责Spider、ItemPipeline、Downloader、Scheduler的工作调度、信息通讯、数据传递等工作 2、Scheduler(调度组件): 负责接收引擎传递过来的请求,按照具体规则添加队列处理,最终返回给引擎 3、Downloader 阅读全文
posted @ 2024-07-16 12:13 donghongchao 阅读(12) 评论(0) 推荐(0) 编辑
摘要:安装: install scrapy # -i https://pipy.douban.com/simple 不一定好用改其他源码 创建scrapy项目的命令: scrapy startproject <项目名字> 创建爬虫命令:在项目路径下执行: `scrapy genspider <爬虫名字> 阅读全文
posted @ 2024-07-16 08:53 donghongchao 阅读(10) 评论(0) 推荐(0) 编辑
摘要:古诗文 验证码登录 方法1:采用bs4可以 import requests # 古诗文网登录页面的URL地址 url = 'https://so.gushiwen.cn/user/login.aspx?from=http://so.gushiwen.cn/user/collect.aspx' hea 阅读全文
posted @ 2024-07-15 15:39 donghongchao 阅读(24) 评论(0) 推荐(0) 编辑
摘要:requests 官方文档: https://requests.readthedocs.io/projects/cn/zh-cn/latest/ 快速上手 https://requests.readthedocs.io/projects/cn/zh-cn/latest/user/quickstart 阅读全文
posted @ 2024-07-14 18:59 donghongchao 阅读(29) 评论(0) 推荐(0) 编辑
摘要:Chrome handless Chrome handless 模式,Google 针对 Chrome 浏览器 59版 新增的一种模式,可以让你不打开 UI 界面的情况下使用 Chrome 浏览器,所以运行效果与 Chrome 保持完美一致 Chrome handless的系统要求 1、Chrome 阅读全文
posted @ 2024-07-14 16:33 donghongchao 阅读(22) 评论(0) 推荐(0) 编辑
摘要:Selenium: 1、selenuim是一个用于web应用程序的工具。 2、selenuim测试直接运行在浏览器中,就像真正的用户在操作一样。 3、支持通过各种driveer(FirfoxDriver,IternetExplorerDriver,OperaDriver,ChromeDriver)驱 阅读全文
posted @ 2024-07-13 19:59 donghongchao 阅读(77) 评论(0) 推荐(0) 编辑
摘要:基本简介: 安装以及创建: 节点定位: 节点信息: 星巴克爬取: from bs4 import BeautifulSoup import urllib.request url = 'https://www.starbucks.com.cn/menu/' resp = urllib.request. 阅读全文
posted @ 2024-07-13 11:38 donghongchao 阅读(9) 评论(0) 推荐(0) 编辑
摘要:pip安装 pip install jsonpath jsonpath的使用 obj = json.load(open('json文件', 'r', encoding='utf‐8')) ret = jsonpath.jsonpath(obj, 'jsonpath语法') jsonpath与lxml 阅读全文
posted @ 2024-07-12 17:30 donghongchao 阅读(70) 评论(0) 推荐(0) 编辑
摘要:解析 xpath使用 安装lxml库 pip install lxml ‐i https://pypi.douban.com/simple pip install lxml -i https://mirrors.aliyun.com/pypi/simple 导入lxml etree from lxm 阅读全文
posted @ 2024-07-11 20:11 donghongchao 阅读(5) 评论(0) 推荐(0) 编辑
摘要:cookie登录 编码反爬 cookie中携带者个人登录信息,如果有登录之后的cookie,那么我们可以携带者cookie进入到任何页面 # 适用的场景:数据采集的时候 需要绕过登陆 然后进入到某个页面 # 个人信息页面是utf-8 但是还报错了编码错误 因为并没有进入到个人信息页面 而是跳转到了登 阅读全文
posted @ 2024-07-11 15:49 donghongchao 阅读(31) 评论(0) 推荐(0) 编辑
摘要:ajax的post请求 import urllib.request import urllib.parse # url = 'https://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname' # # headers = { # 'user- 阅读全文
posted @ 2024-07-11 12:01 donghongchao 阅读(6) 评论(0) 推荐(0) 编辑
摘要:import urllib import urllib.request import urllib.parse import json #分析获取数据 url = 'https://movie.douban.com/j/chart/top_list?type=24&interval_id=100%3 阅读全文
posted @ 2024-07-11 10:38 donghongchao 阅读(6) 评论(0) 推荐(0) 编辑
摘要:get请求豆瓣电影 下载 import urllib.parse import urllib.request import json # url = 'https://movie.douban.com/j/chart/top_list?type=19&interval_id=100%3A90&act 阅读全文
posted @ 2024-07-10 23:47 donghongchao 阅读(3) 评论(0) 推荐(0) 编辑
摘要:# #post请求百度之详细翻译 # import urllib.request # import urllib.parse # url = 'https://fanyi.baidu.com/sug' # data = { # 'kw': "spide" # } # print(data) # da 阅读全文
posted @ 2024-07-10 18:16 donghongchao 阅读(7) 评论(0) 推荐(0) 编辑
摘要:请求对象的定制 import urllib.request url=("https://www.baidu.com") heards = { 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (K 阅读全文
posted @ 2024-07-10 15:50 donghongchao 阅读(4) 评论(0) 推荐(0) 编辑
摘要:url = 'http://www.baidu.com' #模拟浏览器向服务器发送请求 response = urllib.request.urlopen(url) # res = response.read().decode('utf-8') #print(res) #一个类型,六个方法 # pr 阅读全文
posted @ 2024-07-10 10:51 donghongchao 阅读(5) 评论(0) 推荐(0) 编辑
摘要:import urllib.parse import urllib.request def create_request(page): base_url = 'https://movie.douban.com/j/chart/top_list?type=5&interval_id=100%3A90& 阅读全文
posted @ 2024-07-04 07:18 donghongchao 阅读(8) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示