I click the link in Firefox, the webpage sends the request using javascript, then the server sends some kind of response that includes the website address. Therefore, the new website opens in a new window. HTML code behind the link (I missed the start and end <span> tags):
> class="taLnk hvrIE6" > onclick="ta.trackEventOnPage('AttractionContactInfo', 'Website', > 2316062, 1); ta.util.cookie.setPIDCookie(15190); > ta.call('ta.util.link.targetBlank', event, this, > {'aHref':'LqMWJQiMnYQQoqnQQxGEcQQoqnQQWJQzZYUWJQpEcYGII26XombQQoqnQQQQoqnqgoqnQQQQoqnQQQQoqnQQQQoqnqgoqnQQQQoqnQQuuuQQoqnQQQQoqnxioqnQQQQoqnQQJMsVCIpEVMSsVEtHJcSQQoqnQQQQoqnxioqnQQQQoqnQQniaQQoqnQQQQoqnqgoqnQQQQoqnQQWJQzhYmkXHJUokUHnmKTnJXB', > 'isAsdf':true})">Website ', > class="taLnk hvrIE6" > onclick="ta.trackEventOnPage('AttractionContactInfo', 'Website', > 2316062, 1); ta.util.cookie.setPIDCookie(15190); > ta.call('ta.util.link.targetBlank', event, this, > {'aHref':'LqMWJQiMnYQQoqnQQxGEcQQoqnQQWJQzZYUWJQpEcYGII26XombQQoqnQQQQoqnqgoqnQQQQoqnQQQQoqnQQQQoqnqgoqnQQQQoqnQQuuuQQoqnQQQQoqnxioqnQQQQoqnQQJMsVCIpEVMSsVEtHJcSQQoqnQQQQoqnxioqnQQQQoqnQQniaQQoqnQQQQoqnqgoqnQQQQoqnQQWJQzhYmkXHJUokUHnmKTnJXB', > 'isAsdf':true})">Website
I want to capture the server response and extract the βnew siteβ using Python and Selenium. I use BeautifulSoup for scraping and quite new for Selenium.
So far, I can find this element and click on it using selenium, which opens a new site in a new window. I do not know how to capture the response from the server.
python selenium web-scraping
Faisal
source share