0

I am trying to scrape names and contact details from this page https://www.realestate.com.au/find-agent/agents/sydney-cbd-nsw. I normally want to click into each of the list items and get the information from the resulting page, but there is no href to follow.

I'm presuming that the class type somehow points to some JS codes. When the list item is clicked the JS redirects you to the new url. Can I get at it somehow using Scrapy?

Note: I don't know much about JS

2 Answers 2

3

This will give you all the links you need without JS rendering.

response.css('script::text').re('"url":"(.+?)"')

Don't use Chrome for scraping until there's no other way. It's really bad practice.

Sign up to request clarification or add additional context in comments.

Comments

0

I'd recommend using Selenium which will automate an instance of an actual browser. This means that sessions, cookies, javascript execution, etc. is all handled for you.

Example:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("http://example.com")
button = driver.find_element_by_id('buttonID')
button.click()

2 Comments

In fact, selenium is a testing tool not intended to be used for parsing. It's huge computational overhead and noticeably slowing crawler. Way better is to spend some time and reverse engineer some JS, ajax is quite simple
Oh sorry. Thanks for the info though @MichaelSavchenko

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.