0
在此網頁上有一個「顯示學習位置」選項卡,當我單擊該選項卡時,它會顯示整個位置列表並更改我包含在此程序中的網址。當我運行程序來打印出整個位置列表時,我得到這樣的結果:Python:讀取隱藏的HTML表格的內容
soup = BeautifulSoup(urllib2.urlopen('https://clinicaltrials.gov/ct2/show/study/NCT01718158?term=NCT01718158&rank=1&show_locs=Y#locn').read())
for row in soup('table')[5].findAll('tr'):
tds = row('td')
if len(tds)<2:
continue
print tds[0].string, tds[1].string #, '\n'.join(filter(unicode.strip, tds[1].strings))
Local Institution None
Local Institution None
Local Institution None
Local Institution None
Local Institution None
等等.....剩下的信息就出來了。我覺得我在這裏失去了一些東西。我的結果應該是:
United States, California
Va Long Beach Healthcare System
Long Beach, California, United States, 90822
United States, Georgia
Gastrointestinal Specialists Of Georgia Pc
Marietta, Georgia, United States, 30060
United States, New York
Weill Cornell Medical College
等等。我想打印出整個位置列表。
它看起來像內容可以基於用戶代理進行修改或者可能由JavaScript填充。 'wget --no-check-certificate https://clinicaltrials.gov/ct2/show/study/NCT01718158?term=NCT01718158&rank=1&s how_locs = Y'給我一個沒有任何位置的文件,重新尋找。 – Tom 2014-11-21 15:14:27