0

I am unable to extract any data from this website. This code works for other sites. Also, this website is extendable if a registered user scrolls down. How can I extract data from the table from such a website?

from pyquery import PyQuery as pq
import requests

url = "https://uk.tradingview.com/screener/"
content = requests.get(url).content
doc = pq(content)
Tickers = doc(".tv-screener__symbol").text()

Tickers
prashanth manohar
  • 531
  • 1
  • 13
  • 30

1 Answers1

0

You're using a class name which doesn't appear in the source of the page. The most likely reason for this is that the page uses javascript to either load data from a server or change the DOM once the page is loaded to add the class name in question.

Since neither the requests library nor the pyquery library you're using have a javascript engine to duplicate the feat, you get left with the raw static html which doesn't contain the tv-screener__symbol.

To solve this, look at the document you actually receive from a server and try to find the data you're interested in the the raw HTML document you receive:

...
content = requests.get(url).content
print(content)

(Or you can look at the data in the browser, but you must turn off Javascript in order to see the same document that Python gets to see)

If the data isn't in the raw HTML, you have to look at the javascript to see how it makes it's requests to the server backend to load the data, and then copy that request using your python requests' library.

Pascal
  • 448
  • 3
  • 11