There's the website Forbes Most Admired Companies with a list of 50 companies and I am trying to parse that list and export it into a csv
file
The code I have only get me 20 because the page load when you scroll down. is there a way to simulate the scroll down or make it load entirely?
from lxml import html
import requests
def schindler(max): # create a list of the companies
page = requests.get('http://beta.fortune.com/worlds-most-admired-companies/list/')
tempContainer = html.fromstring(page.content)
names = []
position = 1
while position <= max:
names.extend(tempContainer.xpath('//*[@id="pageContent"]/div[2]/div/div/div[1]/div[1]/ul/li['+str(position)+']/a/span[2]/text()'))
position = position + 1
return names
(That was only the list creation, no problem with the .csv exporter)
I then print it to chek and only 20 items appear in the list
print(schindler(50))