爬蟲 解析頁面 拆分字段存入不同key

2021-10-08 02:47:49 字數 583 閱讀 8256

存到字典中最後想要的效果,data[「author」] = 佚名,data[「source」] = 轉化醫學網,data[date] = 2020-07-13

將原始字段拆分,for迴圈遍歷,用:拆分得到對應的 key 和 value

將key與dict1對應

————————————附上**—————————————

author_source_pubtime = sel.xpath("//div[@class='y-coot-lefts']/div[1]/text()").extract()

dict1 =

author_source_pubtime = author_source_pubtime[0].replace("整理",'').split()

# print(author_source_pubtime)

for a_s_p in author_source_pubtime:

x = a_s_p.split(":")[0]

y = a_s_p.split(":")[1]

data[dict1[x]] = y

Ntext欄位拆分處理

if exists select from dbo.sysobjects where id object id n dbo p split and objectproperty id,n isprocedure 1 drop procedure dbo p split go ntext欄位拆分處理 ...

Ntext欄位拆分處理

if exists select from dbo.sysobjects where id object id n dbo p split and objectproperty id,n isprocedure 1 drop procedure dbo p split go ntext欄位拆分處理 ...

Ntext欄位拆分處理

if exists select from dbo.sysobjects where id object id n dbo p split and objectproperty id,n isprocedure 1 drop procedure dbo p split go ntext欄位拆分處理 ...