0

The old script was working until yesterday. In page source it used to display the web content, e.g. "IssuesTraded 3,037 3,025 3,030", but not any more.. can't figure out what changed..

browser = webdriver.Chrome(executable_path=r"C:/Windows/chromedriver.exe")

urlpage = 'https://www.wsj.com/market-data/stocks/marketsdiary'
browser.get(urlpage)
results = browser.find_elements_by_xpath("//*[@id='root']//*[@class='style--grid--3gzjbqou ']")

# print('Number of results', len(results))
data = []
for result in results:
    data.append(result.text)

data = [x.split("\n") for x in data]
data = [y for x in data for y in x]

1 Answer 1

1

It looks like you have linked to a class name that can change dynamically:

results = browser.find_elements_by_xpath("//*[@id='root']//*[@class='style--grid--3gzjbqou ']")

They probably updated the app, so 3gzjbqou is no longer there. Instead of linking to the full class name, you can make this locator more stable by removing 3gzjbqou piece and only link to the part of that class.

So try this line instead of yours for searching results:

results = browser.find_elements_by_xpath("//*[@id='root']//*[contains(@class, 'style--grid')]")

I hope this helps, good luck!

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

Comments

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.