I have an issue, I would like to scrap all french stocks (10 pages) through this website : https://www.zonebourse.com/bourse/actions/Europe-3/France-51
but when I go to the 2nd page, the end of the url is random, for example :
once it's zonebourse.com/bourse/actions/Europe-3/France-51/_BF3L50/
then another time it's zonebourse.com/bourse/actions/Europe-3/France-51/_4FXnaa/
etc
it's the same issue for the others pages too ..
there is no pattern ! How can I do ?
Here my code if the url was
zonebourse.com/bourse/actions/Europe-3/France-51/1
zonebourse.com/bourse/actions/Europe-3/France-51/2
...
import requests
from bs4 import BeautifulSoup
links = []
for i in range(10):
url = 'https://www.zonebourse.com/bourse/actions/Europe-3/France-51/' + str(i)
response = requests.get(url)
if response.ok:
soup = BeautifulSoup(response.text, 'lxml')
tds = soup.findAll('td')
for td in tds:
a = td.find('a')
if a != None:
link = a['href']
if link.startswith('/cours/action/'):
links.append('https://www.zonebourse.com'+link)
print(links)
thanks !