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

做网站前端需要编程基础吗如何做关于旅游的网站页面

做网站前端需要编程基础吗,如何做关于旅游的网站页面,小游戏开发需要多少钱,东莞seo优化培训本项目纯学习使用。 1 scrapy 代码 爬取逻辑非常简单,根据url来处理翻页,然后获取到详情页面的链接,再去爬取详情页面的内容即可,最终数据落地到excel中。 经测试,总计获取 11299条中医药材数据。 import pandas as…

本项目纯学习使用。

1 scrapy 代码

爬取逻辑非常简单,根据url来处理翻页,然后获取到详情页面的链接,再去爬取详情页面的内容即可,最终数据落地到excel中。
经测试,总计获取 11299条中医药材数据。

import pandas as pd
import scrapyclass ZhongyaoSpider(scrapy.Spider):name = "zhongyao"start_urls = [f"https://www.zysj.com.cn/zhongyaocai/index__{i}.html" for i in range(1, 27)]def __init__(self, *args, **kwargs):self.data = []def parse(self, response):for li in response.css('div#list-content ul li'):a_tag = li.css('a')title = a_tag.css('::attr(title)').get()href = a_tag.css('::attr(href)').get()if title and href:# 构建完整的详情页 URLdetail_url = response.urljoin(href)yield scrapy.Request(detail_url, callback=self.parse_detail, meta={'title': title})# 解析逻辑def parse_detail(self, response):title = response.meta['title']pinyin = response.css('div.item.pinyin_name_phonetic div.item-content::text').get(default='').strip()alias = response.css('div.item.alias div.item-content p::text').get(default='').strip()english_name = response.css('div.item.english_name div.item-content::text').get(default='').strip()source = response.css('div.item.alias div.item-content p::text').get(default='').strip()# 性味flavor = response.css('div.item.flavor div.item-content p::text').get(default='').strip()functional_indications = response.css('div.item.flavor div.item-content p::text').get(default='').strip()usage = response.css('div.item.usage div.item-content p::text').get(default='').strip()excerpt = response.css('div.item.excerpt div.item-content::text').get(default='').strip()#habitat = response.css('div.item.habitat div.item-content p::text').get(default='').strip()# 出处provenance = response.css('div.item.provenance div.item-content p::text').get(default='').strip()# 性状shape_properties = response.css('div.item.shape_properties div.item-content p::text').get(default='').strip()# 归经attribution = response.css('div.item.attribution div.item-content p::text').get(default='').strip()#  原形态prototype = response.css('div.item.prototype div.item-content p::text').get(default='').strip()# 名家论述discuss = response.css('div.item.discuss div.item-content p::text').get(default='').strip()# 化学成分chemical_composition = response.css('div.item.chemical_composition div.item-content p::text').get(default='').strip()item = {'title': title,'pinyin': pinyin,'alias': alias,'source': source,'english_name': english_name,'habitat': habitat,'flavor': flavor,'functional_indications': functional_indications,'usage': usage,'excerpt': excerpt,'provenance': provenance,'shape_properties': shape_properties,'attribution':  attribution,'prototype': prototype,'discuss': discuss,'chemical_composition': chemical_composition,}self.data.append(item)yield itemdef closed(self, reason):# 当爬虫关闭时,保存数据到 Excel 文件df = pd.DataFrame(self.data)df.to_excel('zhongyao_data.xlsx', index=False)

2 爬取截图

在这里插入图片描述

3 爬取数据截图

在这里插入图片描述

http://www.yayakq.cn/news/140045/

相关文章:

  • 深圳网站建设知名公司wordpress申请子站
  • 网站建设计入哪个明细科目深圳专业seo
  • 上海找做网站公司哪家好网站建设学什么语言
  • 网站开发技术栈企业网站建设 论文
  • 重庆网站建设入门培训优化合作平台
  • 无极在线网站播放wordpress管理登录
  • 竞猜网站建设直播开放平台登陆
  • 图书馆网站建设汇报长沙优质营销网站建设设计
  • 网络公司代做的网站注意事项wordpress 会员支付
  • 广州建论坛网站门户网站用什么后台系统好
  • 自己做视频会员网站自己怎么建个免费网站吗
  • 怎样才能有自己的网站做淘宝这种网站
  • 做软装找产品上哪个网站企业网站开发的功能
  • 云建造网站电子商务网站如何推广
  • 网站数据采集 源码seo知识点
  • 深圳珠宝品牌网站设计金融网站开发的意义 论文
  • 做ic芯片的要去哪个网站wordpress 主题 500
  • 天行健君子以自强不息网站建设做淘宝美工和网站设计那个好
  • 做网站需要什么服务器配置软件开发专业单词
  • 广州做网站哪家强企业推广是做什么的
  • 深圳品牌营销网站建设android开发基础教程
  • 国内网站空间主机网站维护 代码
  • 做网站的工具 论坛电子商务网站建设如何策划与实施
  • 数据网站建设多少钱浏阳网站建设
  • 做爰全过程免费的视频 网站重庆网站开发哪家专业
  • 移动网站趋势WordPress美图主题
  • html 动漫网站wordpress设置首页
  • 网站建设在什么税控盘龙溪营销型网站制作
  • 建设配资网站有要求吗浅谈电子商务网站建设与规划
  • 网站开发人员薪酬公司网站规划