2
我通過.csv合約迭代,嘗試從網站中提取單個列。使用BeautifulSoup和Python抓取格式不完整的表中的一列
我要搶標「商品名稱」從表在網頁的最後一列。但是,我無法弄清楚如何抓取列 - 只是行。
這是我目前正在
def scraper(first, second, third):
url = "https://www.austintexas.gov/financeonline/contract_catalog/OCCViewMA.cfm?cd=%s&dd=%d&id=%s" % (first, second, third)
soup = BeautifulSoup(urllib2.urlopen(url).read())
foundtext = soup.find('td',text="Commodity Description")
table = foundtext.findPrevious('table')
rows = table.findAll('tr')
second_column = []
for row in rows:
print row.contents
我想最終輸出返回從該列中所有行的文本與行之間返回車廂使用的代碼。
有什麼想法?
輝煌!謝謝一堆 – Parseltongue