N07 - 随机CSS样式类名,无Element ID
# coding=utf-8 import requests from lxml import etree base_url = 'https://spiderbuf.cn/playground/n07' my_headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36'} # 取页数 html_bytes = requests.get(base_url,...
The current Flask app is not registered with this 'SQLAlchemy' instance.
The current Flask app is not registered with this 'SQLAlchemy' instance. Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances? 使用Flask开发Web应用时,必不可少的就是使用SQL Alchemy对数据库进行操作。但是经常会看到有些人遇到一个报错,就是以上这些报错提示。 这样的报错通常发生在保存数据及提交时,如以下代码: ```python db.session.add(spiderbuf) db...
E04 - 被屏蔽IP后使用代理服务器爬取页面
# coding=utf-8 import requests from lxml import etree import re base_url = 'https://spiderbuf.cn/playground/e04' myheaders = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36'} proxies = {'http':'47.122.65.254...
PyCharm调试时报错:can't open file 'C:\\Program': [Errno 2] No such file or directory
C:\Python\python.exe: can't open file 'C:\\Program': [Errno 2] No such file or directory Process finished with exit code 2 最近在升级PyCharm时,一时忘记修改默认的安装路径,在写代码并且调试模式(Debug)运行时就报了以上的错误。隐约记得在网上也见过有网友遇过这样的问题并且发贴求助,所以就记录一下。 先说解决方法:这个问题就是由于PyCharm安装路径带了空格导致的,重新安装PyCharm并在安装时选择不带空格及中文的路径即可。 所以我在很多时候都会强调写...
Ubuntu 安装配置Playwright
Playwright 是一个由 Microsoft 开发的开源自动化库,它允许开发者以编程的方式控制 Chromium,Firefox和 WebKit 这样的现代浏览器。Playwright 能够执行跨浏览器的端到端测试,非常适合自动化测试、爬虫开发以及生成网页截图和 PDF。本文将指导你在 Ubuntu 系统上安装和配置Playwright。 #### Ubuntu环境配置 先打开Ubuntu终端,执行以下命令安装Playwright的依赖库:...