2016-08-10 25 views
-2

你好,我有我的代碼有問題,我試圖尋找一個特定的URL與此代碼,但它不會顯示任何東西錯誤的代碼的Python Beautifulsoup提取與文本的特定鏈接

from BeautifulSoup import BeautifulSoup 
import urllib2 
import re 

html_page = urllib2.urlopen(url) 
soup = BeautifulSoup(html_page) 
for link in soup.findAll('a', attrs={'href': re.compile("^http://www.fiuxy.net/misc.php")}): 
    print link.get('href') 

enter image description here

我只想要它有「10」文字的鏈接,它每次都會改變,(每次都不一樣)

我做得不好嗎?

很抱歉,如果我的英語不好bcause IM西班牙:(

+0

'soup.select( 'DAR-puntos> A') [-1] .text' –

+0

我在那裏添加了?@AvinashRaj –

+0

替換爲上面的循環,並且不要忘記在此之前添加打印。 –

回答

1

謝謝大家,但我解決它自己硒,

from selenium import webdriver 
driver.get(url) 
puntos = driver.find_element_by_link_text(u"10") 
print (puntos.get_attribute('href')) 
相關問題