Can't get all names with selenium from Facebook - Python 3
<p>i'm creating a scraper using python and selenium to improve my ability with python.
I'm having trouble with selecting certain elements.</p>

<p>On facebook i'm trying to scrape the list of someone friends. 
This is the piece of code i wrote</p>

<pre><code>nomifb = driver.find_elements_by_xpath("//div[@class='fsl fwb fcb']")
print("We've found " + str(len(nomifb)) + " friends!")"
file = open(filename, "w")
for i in range(len(nomifb)):
    nomifb_txt.append(nomifb[i].text)
nomifb_txt.sort()
for i in range(len(nomifb)):
    file.write(nomifb_txt[i] + "\n")
file.close()
</code></pre>

<p>I get the div the contain the names using the "fsl fwb fcb" classes. That seems to be working on people with not a lot of friends.
If i get over 400 friends it seems to miss about 5% of it, and i cant seem to figure out why :/ </p>

<p>Is there anyway to improve the find_elements so that i get every person name? </p>

<p>I checked with chrome to see if there was any problem with my script but it seems that the "fsl fwb fcb" tag is used less time than the total number of friends and there lies the problem</p>

<p>Also i seems to have a too-hacky solution for the scrolldown, it goes down until it find</p>

<pre><code>element = driver.find_element_by_xpath("//*[contains(text(), 'Altre informazioni su')]")
</code></pre>

<p>Which is "Other information about" but as you can see it lack the support for other languages.
How would i go about selecting it in a better way? </p>

<p>Sorry for the newbie question, hope you can spare a moment to teach me better :)</p>

<p>Cheers </p>

<p>EDIT I've seemed to fix it! The problem was that facebook count in the friends number also deleted account, and that's where the discrepancy come from. </p>

<p>you can try by element name
<code>element = driver.find_element_by_name("name of tag")</code></p>

python facebook python-3.x selenium screen-scraping