国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

公司怎么制作網(wǎng)站免費發(fā)帖推廣網(wǎng)站

公司怎么制作網(wǎng)站,免費發(fā)帖推廣網(wǎng)站,網(wǎng)站如何配置域名,自建個人網(wǎng)站一.最終效果 二.項目代碼 2.1 新建項目 本文使用scrapy分布式、多線程爬蟲框架編寫的高性能爬蟲,因此新建、運行scrapy項目3步驟: 1.新建項目: scrapy startproject weibo_hot 2.新建 spider: scrapy genspider hot_search "weibo.com" 3…

一.最終效果

二.項目代碼

2.1 新建項目

本文使用scrapy分布式、多線程爬蟲框架編寫的高性能爬蟲,因此新建、運行scrapy項目3步驟:

1.新建項目:
scrapy startproject weibo_hot

2.新建 spider:
scrapy genspider hot_search "weibo.com"

3.運行 spider:
scrapy crawl hot_search

注意:hot_search 是spider中的name

4.編寫item:

class WeiboHotItem(scrapy.Item):index = scrapy.Field()topic_flag = scrapy.Field()icon_desc_color = scrapy.Field()small_icon_desc = scrapy.Field()small_icon_desc_color = scrapy.Field()is_hot = scrapy.Field()is_gov = scrapy.Field()note = scrapy.Field()mid = scrapy.Field()url = scrapy.Field()flag = scrapy.Field()name = scrapy.Field()word = scrapy.Field()pos = scrapy.Field()icon_desc = scrapy.Field()

5.編寫爬蟲解析代碼:


import os
from itemadapter import ItemAdapter
from .settings import DATA_URI
from .Utils import Tooltool = Tool()class WeiboHotPipeline:def open_spider(self, spider):self.hot_line = "index,mid,word,label_name,raw_hot,category,onboard_time\n"data_dir = os.path.join(DATA_URI)file_path = data_dir + '/hot.csv'#判斷文件夾存放的位置是否存在,不存在則新建文件夾if os.path.isfile(file_path):self.data_file = open(file_path, 'a', encoding='utf-8')else:if not os.path.exists(data_dir):os.makedirs(data_dir)self.data_file = open(file_path, 'a', encoding='utf-8')self.data_file.write(self.hot_line)def close_spider(self, spider):  # 在關閉一個spider的時候自動運行self.data_file.close()def process_item(self, item, spider):try:hot_line = '{},{},{},{},{},{},{}\n'.format(item.get('index', ''),item.get('mid', ''),item.get('word', ''),item.get('label_name', ''),item.get('raw_hot', ''),tool.translate_chars(item.get('category', '')),tool.get_format_time(item.get('onboard_time', '')),)self.data_file.write(hot_line)except BaseException as e:print("hot錯誤在這里>>>>>>>>>>>>>", e, "<<<<<<<<<<<<<錯誤在這里")return item

三.注意事項

settings.py配置項修改


# Obey robots.txt rules
ROBOTSTXT_OBEY = False # 關閉,否則根據(jù)weibo的爬蟲策略爬蟲無法獲取數(shù)據(jù)

如果

四.運行過程

五.項目說明文檔

六.獲取完整源碼

愛學習的小伙伴,本次案例的完整源碼,已上傳微信公眾號“一個努力奔跑的snail”,后臺回復 熱搜榜 即可獲取。

http://aloenet.com.cn/news/36989.html

相關文章:

  • 吉林省建設廳網(wǎng)站首頁域名??烤W(wǎng)頁推廣大全
  • 網(wǎng)站功能設計的內(nèi)容個人怎么注冊自己的網(wǎng)站
  • 無貨源電商平臺有哪些廈門站長優(yōu)化工具
  • 廣告?zhèn)髅焦揪W(wǎng)站網(wǎng)站推廣策劃報告
  • html5網(wǎng)站開發(fā)的源碼網(wǎng)絡顧問
  • 西藏建設廳網(wǎng)站首頁seo科技網(wǎng)
  • 做視頻網(wǎng)站虛擬主機怎么選廣告聯(lián)盟接廣告
  • wordpress 采集圖片seo排名點擊首頁
  • 怎么用服務器搭建網(wǎng)站推廣之家app下載
  • 公司名稱注冊查詢系統(tǒng)seo營銷工具
  • wordpress漂亮的主題網(wǎng)站seo優(yōu)化有哪些方面
  • 商丘做網(wǎng)站sqlongliqi市場營銷四大基本策略
  • linux如何架設網(wǎng)站貴陽網(wǎng)絡推廣排名
  • 微信小程序視頻網(wǎng)站開發(fā)教程靜態(tài)網(wǎng)頁制作
  • 網(wǎng)站建設圖片怎么做免費b站網(wǎng)頁推廣
  • 網(wǎng)站做數(shù)據(jù)分析的意義北京百度推廣投訴電話
  • 做網(wǎng)站營業(yè)執(zhí)照經(jīng)營范圍怎么填寫免費seo排名軟件
  • 做公司網(wǎng)站用什么系統(tǒng)上海疫情最新數(shù)據(jù)
  • 淮安市哪里可以做網(wǎng)站開魯視頻
  • wordpress頁面教程視頻小紅書搜索優(yōu)化
  • 商標 做網(wǎng)站 是幾類站長工具天美傳媒
  • 雅安交通建設集團網(wǎng)站太原網(wǎng)絡推廣公司哪家好
  • 鄭州網(wǎng)站建設網(wǎng)站制作百度官網(wǎng)推廣平臺電話
  • 輕云服務器 多個網(wǎng)站今日頭條鄭州頭條新聞
  • 泉州網(wǎng)站制作專業(yè)產(chǎn)品怎么做市場推廣
  • 網(wǎng)站建設的常用詞搜收錄網(wǎng)
  • 動態(tài)購物網(wǎng)站開發(fā)源代碼西地那非能提高硬度嗎
  • 做網(wǎng)站能拿多少錢淘寶指數(shù)查詢工具
  • 電信服務器做網(wǎng)站網(wǎng)絡整合營銷理論案例
  • 織夢響應式茶葉網(wǎng)站流感用什么藥最好