我将尝试使用Python + Selenium从一个标签中获取href,但是href中包含了"JavaScript",所以我无法获得目标URL。
我正在使用Python 3.7.3和selenium 3.141.0。
HTML:
我正在使用Python 3.7.3和selenium 3.141.0。
HTML:
<a href="javascript:GoPDF('FS1546')" style="TEXT-DECORATION: Underline">Aberdeen Standard Wholesale Australian Fixed Income</a>
代码:
from selenium import webdriver
driver = webdriver.Chrome("chromedriver.exe")
driver.get("http://www.colonialfirststate.com.au/Price_performance/performanceNPrice.aspx?menutabtype=performance&CompanyCode=001&Public=1&MainGroup=IF&BrandName=FC&ProductIDs=91&Product=FirstChoice+Wholesale+Investments&ACCodes=&ACText=&SearchType=Performance&Multi=False&Hedge=False&IvstType=Investment+products&IvstGroup=&APIR=&FundIDs=&FundName=&FundNames=&SearchProdIDs=&Redirect=1")
print(driver.find_elements_by_xpath("tbody/tr[5]/td[1]/a")
我需要的是目标URL
,格式为:
但是它给了我:https://www3.colonialfirststate.com.au/content/dam/prospects/fs/1/5/fs1546.pdf?3
javascript:GoPDF('FS2311')