- 博客(12)
- 问答 (1)
- 收藏
- 关注
原创 pyspider centos 环境报错 需要降低部分包版本
pip install flask==1.0python -m pip install werkzeug==0.16.1pip install wsgidav==2.4.1
2024-02-15 12:51:57 364
原创 python 读取大文件
def myreadlines(f, newline): buf = "" while True: while newline in buf: pos = buf.index(newline) yield buf[:pos] buf = buf[pos+len(newline):] chunk = f.read(12) if not chunk: ..
2022-04-14 14:59:54 597
转载 python 生成器的原理
Python函数生成器原理及使用详解 / 张生荣Python函数生成器原理及使用详解 1.python函数运行原理 import inspect frame = None def foo(): bar() def bar(): global frame frame = inspect.currentframe() pass # python解释器 python.exe 会用一个叫做PyEval_EvalFrameEx(c语言函数)去执行foo函数,首先会创建一个栈帧(stack frame), """ py
2022-04-14 14:57:23 160
原创 python 实现Fibonacci
# 递归方式求斐波那契数列第n位def fib1(index): if index <= 2: return 1 else: return fib1(index-1)+fib1(index-2)# 返回前n位 斐波那契列表def fib2(index): re_list = [] n,a,b = 0,0,1 while n < index: re_list.append(b) a,.
2022-04-14 14:48:55 729
原创 几种js渲染方式的demo
几种js渲染方式的demo使用selenium使用requests_html(基于pyppeteer)使用splash使用pyppeteer使用seleniumimport selenium.webdriverimport timeimport selenium.webdriverclass Spider(object): def __init__(self): self.spidername="xxx_com" self.chromedriver_pat
2020-08-25 10:26:12 497
原创 centos 上python2和python3共存之后防火墙修改
vim /usr/sbin/firewalld vim /usr/bin/firewall-cmd这俩处改为python2的执行环境,否则防火墙相关命令将无法正常使用
2019-10-11 10:51:27 143
原创 centos7 安装pyspider遇到的坑
不要用最新版本的python,否则会有一堆错误要改 pycurl安装报错 参考这位大佬博客Liu-YanLin》https://blog.csdn.net/qq_32502511/article/details/80606636 最后又出现 Deprecated option 'domaincontroller': use 'http_authenticator.domain_...
2019-10-11 10:43:30 271
原创 python aiohttp遇到的坑
出现 missing 1 required positional argument: 'url'" 多半是写错了, 例如 正确写法 程序可以正常运行,但出现 client_session: <aiohttp.client.ClientSession object at 0x000000000CC98908> Unclosed connector ...
2019-10-10 13:48:07 967
原创 爬虫学习笔记(点击加载内容的爬取)-001
今天再爬一个网站时遇到通过jsonp的形式回传后续内容的网站 (如图):经过观察发现每点击一个这个按钮,浏览器就会发送两个get请求: 而第一个参数里边返回的内容正好是我们要的东西,此时再看它的url:https://shankapi.ifeng.com/shanklist/_/getColumnInfo/_/default/6470973085922103296/154280...
2018-11-22 16:25:42 5377 1
原创 app抽取数据时小细节(post请求-pyspider框架)
1. 最好不要把headers写在crawl_config 中,并注意是正确的json格式2. 有的headers 中的东西并不需要添加,添加反而会报错3. self.crawl() 中的data 参数 需要区分是以字典形式传还是字符串形式 ...
2018-11-20 18:03:51 292
原创 pyspider 构造多个post请求
今天爬取一个网站时,发现网站列表数据都是post回传,data参数变化,如果直接用如下的方式写:def on_start(self): s = [1,2,3,4,5,6,7] for i in s: for x in range(1,20): data = { 'm...
2018-11-15 15:42:30 571
空空如也
通过分析发出去的两个get请求从而获取这个网页分页信息?
2018-11-22
TA创建的收藏夹 TA关注的收藏夹
TA关注的人