【发布时间】:2015-01-26 22:07:55
【问题描述】:
我有一个表格,在下面找到并存储为“表格”。它包含以下内容:
我的代码捕获了正确的信息,但我需要知道如何将每条信息放入它自己的变量中。感谢您对此提供的任何帮助,我只玩 BeautifulSoup 一个星期,所以请原谅我。我翻遍了整个堆栈,但没有找到适合我的答案。
这是我看到的输出:http://pastebin.com/fiYQvBix
import sys, locale, os, re, urllib2
import lxml.etree, requests
from bs4 import BeautifulSoup as bSoup
# Website that we are scraping:
BASE_URL = 'https://www.biddergy.com/detail.asp?id='
#ID = raw_input("Enter listing #: ")
ID = str(330998) # defined constant for debugging
# Store response in soup:
response = requests.get(BASE_URL+ID)
soup = bSoup(response.text)
# Find auction info <table>
table = soup.find('table', cellpadding="2")
#### Everything above this line works great ####
for row in table.find_all('tr'):
for col in row.find_all("td"):
print(col.string)
【问题讨论】:
标签: python web-scraping beautifulsoup html-table