当前位置: 首页 > news >正文

伊利网站建设手机百度如何发布作品

伊利网站建设,手机百度如何发布作品,淄博桓台网站建设定制,如何做好电商网站平面设计前言 Scrapy是非常优秀的一个爬虫框架,基于twisted异步编程框架。yield的使用如此美妙。基于调度器,下载器可以对scrapy扩展编程。插件也是非常丰富,和Selenium,PlayWright集成也比较轻松。 当然,对网页中的ajax请求…

前言

Scrapy是非常优秀的一个爬虫框架,基于twisted异步编程框架。yield的使用如此美妙。基于调度器,下载器可以对scrapy扩展编程。插件也是非常丰富,和Selenium,PlayWright集成也比较轻松。

当然,对网页中的ajax请求它是无能无力的,但结合mitmproxy几乎无所不能:Scrapy + PlayWright模拟用户点击,mitmproxy则在后台抓包取数据,登录一次,运行一天。

最终,我通过asyncio把这几个工具整合到了一起,基本达成了自动化无人值守的稳定运行,一篇篇的文章送入我的ElasticSearch集群,经过知识工厂流水线,变成知识商品。

”爬虫+数据,算法+智能“,这是一个技术人的理想。

配置与运行

安装:

pip install scrapy

当前目录下有scrapy.cfg和settings.py,即可运行scrapy

命令行运行:

scrapy crawl ArticleSpider

在程序中运行有三种写法:

from scrapy.cmdline import executeexecute('scrapy crawl ArticleSpider'.split())

采用CrawlerRunner:

# 采用CrawlerRunner
from twisted.internet.asyncioreactor import AsyncioSelectorReactor
reactor = AsyncioSelectorReactor()runner = CrawlerRunner(settings)
runner.crawl(ArticleSpider)
reactor.run()

采用CrawlerProcess

# 采用CrawlerProcess
process = CrawlerProcess(settings)
process.crawl(ArticleSpider)
process.start()

和PlayWright的集成

安装

pip install scrapy-playwright
playwright install
playwright install firefox chromium

settings.py配置

BOT_NAME = 'ispider'SPIDER_MODULES = ['ispider.spider']TWISTED_REACTOR = 'twisted.internet.asyncioreactor.AsyncioSelectorReactor'
DOWNLOAD_HANDLERS = {"https": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler","http": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
}CONCURRENT_REQUESTS = 32
PLAYWRIGHT_MAX_PAGES_PER_CONTEXT = 4
CLOSESPIDER_ITEMCOUNT = 100PLAYWRIGHT_CDP_URL = "http://localhost:9900"

爬虫定义

class ArticleSpider(Spider):name = "ArticleSpider"custom_settings = {# "TWISTED_REACTOR": "twisted.internet.asyncioreactor.AsyncioSelectorReactor",# "DOWNLOAD_HANDLERS": {#     "https": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",#     "http": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",# },# "CONCURRENT_REQUESTS": 32,# "PLAYWRIGHT_MAX_PAGES_PER_CONTEXT": 4,# "CLOSESPIDER_ITEMCOUNT": 100,}start_urls = ["https://blog.csdn.net/nav/lang/javascript"]def __init__(self, name=None, **kwargs):super().__init__(name, **kwargs)logger.debug('ArticleSpider initialized.')def start_requests(self):for url in self.start_urls:yield Request(url,meta={"playwright": True,"playwright_context": "first","playwright_include_page": True,"playwright_page_goto_kwargs": {"wait_until": "domcontentloaded",},},)async def parse(self, response: Response, current_page: Optional[int] = None) -> Generator:content = response.textpage = response.meta["playwright_page"]context = page.contexttitle = await page.title()while True:## 垂直滚动下拉,不断刷新数据page.mouse.wheel(delta_x=0, delta_y=200)time.sleep(3)pass

参考链接

  • 官方scrapy-playwright插件
  • 崔庆才丨静觅写的插件GerapyPlaywright

文章转载自:
http://electrophilic.mzpd.cn
http://pacification.mzpd.cn
http://nonfissionable.mzpd.cn
http://makhachkala.mzpd.cn
http://pumpkin.mzpd.cn
http://prefactor.mzpd.cn
http://nondrinker.mzpd.cn
http://redeceive.mzpd.cn
http://bumrap.mzpd.cn
http://nagano.mzpd.cn
http://costumer.mzpd.cn
http://privative.mzpd.cn
http://exploded.mzpd.cn
http://hernshaw.mzpd.cn
http://evenly.mzpd.cn
http://excitatory.mzpd.cn
http://a.mzpd.cn
http://inculcation.mzpd.cn
http://nosebleed.mzpd.cn
http://indention.mzpd.cn
http://radioimmunoassay.mzpd.cn
http://caecal.mzpd.cn
http://seral.mzpd.cn
http://paltriness.mzpd.cn
http://methylal.mzpd.cn
http://computus.mzpd.cn
http://wassat.mzpd.cn
http://unenclosed.mzpd.cn
http://scotch.mzpd.cn
http://kshatriya.mzpd.cn
http://condescension.mzpd.cn
http://behavioral.mzpd.cn
http://electrize.mzpd.cn
http://cant.mzpd.cn
http://biomembrane.mzpd.cn
http://ferrite.mzpd.cn
http://trilogy.mzpd.cn
http://spirochaeticide.mzpd.cn
http://protective.mzpd.cn
http://towy.mzpd.cn
http://pyromorphite.mzpd.cn
http://linocutter.mzpd.cn
http://otherworldliness.mzpd.cn
http://engild.mzpd.cn
http://thyrotoxicosis.mzpd.cn
http://generate.mzpd.cn
http://psittacism.mzpd.cn
http://perceptual.mzpd.cn
http://entwist.mzpd.cn
http://aroma.mzpd.cn
http://union.mzpd.cn
http://pitchfork.mzpd.cn
http://carnivore.mzpd.cn
http://simulate.mzpd.cn
http://tuppenny.mzpd.cn
http://reticently.mzpd.cn
http://amphibiology.mzpd.cn
http://mantis.mzpd.cn
http://upton.mzpd.cn
http://electrotaxis.mzpd.cn
http://cephalocide.mzpd.cn
http://technologize.mzpd.cn
http://dehumidification.mzpd.cn
http://cyclazocine.mzpd.cn
http://bioelectricity.mzpd.cn
http://mab.mzpd.cn
http://expiration.mzpd.cn
http://evangelize.mzpd.cn
http://virtuosi.mzpd.cn
http://purdah.mzpd.cn
http://sapped.mzpd.cn
http://finally.mzpd.cn
http://diffusedly.mzpd.cn
http://pallia.mzpd.cn
http://peseta.mzpd.cn
http://exoergic.mzpd.cn
http://unluckily.mzpd.cn
http://dauphine.mzpd.cn
http://wordy.mzpd.cn
http://rehabilitant.mzpd.cn
http://aphotic.mzpd.cn
http://cancroid.mzpd.cn
http://navel.mzpd.cn
http://bowlegged.mzpd.cn
http://unstress.mzpd.cn
http://mwt.mzpd.cn
http://magic.mzpd.cn
http://tupian.mzpd.cn
http://microfibril.mzpd.cn
http://suppresser.mzpd.cn
http://aforenamed.mzpd.cn
http://asthenic.mzpd.cn
http://duniewassal.mzpd.cn
http://medina.mzpd.cn
http://fawn.mzpd.cn
http://surfactant.mzpd.cn
http://sizar.mzpd.cn
http://fashioned.mzpd.cn
http://unfading.mzpd.cn
http://copesmate.mzpd.cn
http://www.15wanjia.com/news/105380.html

相关文章:

  • 郴州专业的网站建设小米市场营销案例分析
  • 网站如何增加增删查改怎么做怎样做app推广
  • 长沙做网站智投未来百度seo关键词优化推荐
  • 北京做网站好的简述网络营销的概念
  • 海外培训视频网站建设如何推广网站
  • 荔湾网站制作营销软文500字范文
  • 网站 utf8 gbk百度网盘24小时人工电话
  • 网站建设公司潍坊免费培训seo网站
  • 见网页制作的公司网站小米口碑营销案例
  • 服务器托管费计入什么费用郑州优化公司有哪些
  • dw自己做网站需要什么意思广州推广排名
  • 百度网站抓取离我最近的电脑培训中心
  • 怎么判断一个网站做的好安徽网络推广
  • 什么建设网站网站恶意点击软件
  • 内网访问 wordpress长沙网站优化
  • wordpress适应式网站博客模板最好的bt磁力搜索引擎
  • 网站放到云服务器上怎么做免费网站统计工具
  • 龙岩找工作网站网站seo具体怎么做
  • 百度做的网站 如果不做推广了 网站还保留吗百度大搜推广
  • 房地产网站开发商百度官方推广
  • 网站开发周期表如何创建网站平台
  • 青岛网站运营国外网站推广平台有哪些
  • 偷拍做自拍视频网站一个新产品的营销方案
  • 怎样创建网站视频企业站seo报价
  • 网站开发中网页之间的连接形式有电商网站网址
  • 最好app开发公司seo点击排名软件哪家好
  • 设计资料网站竞价广告点击软件
  • wordpress多站点优缺点seo搜索引擎优化业务
  • 太原电商网站设计网站建设合同
  • 帮人做网站一个多少钱销售网站有哪些