使用beautfiulsoup解析源代碼刮:Python的正則表達式字符串排除
tempSite = preSite+'/contact_us/'
print tempSite
theTempSite = urlopen(tempSite).read()
currentTempSite = BeautifulSoup(theTempSite)
lightwaveEmail = currentTempSite('input')[7]
#<input type="Hidden" name="bb_recipient" value="[email protected]" />
我怎麼能re.compile lightwaveEmail因此只有[email protected]打印?
標記和歸因幫助很大,但我仍然不是很讓我在尋找的輸出:在這種情況下,它現在印刷[] - 我想顯式拼接值字段作爲唯一的輸出。 – Hikalea
Urp ..檢查更新.. – synthesizerpatel
'.findAll()'返回一個列表。使用'soup.find('input',dict(name =「bb_recipient」,value = True))'獲取第一個找到的元素。 – jfs