今天爬取详细信息准备从详细信息中提取地址信息,药品的详细信息就存放在一个table表格中当爬取整个表格的时候只爬取第一个td中的标题信息,而第二列中td还包含一个span标签,其中的内容没有爬取到
直接爬取
for tr in trs: ui = [] for td in tr: ui.append(td.string) ulist.append(ui)
经过修改爬取
for tr in trs: for td in tr: #print(td.string) #print (td) if td.string == "药材名称": spans = tr.find('span')#获取span标签中的数据 #ui.append(td.string) ulist.append(spans) #ulist.append(ui)
修改后
标签中还是存在一些杂乱信息,还需要用正则进行处理