This is the follow up to my first selenium post which gave a good example of how one could scrape facebook with python. If we go more into detail, the first post gave an example of how to invite friends to your facebook page with python using selenium package. As this was a good exercise, I wanted to do a follow up. The following python code mainly uses selenium with a bit of help from BeautifulSoup, which by the way is another great web scraping tool which I will start to use more often.
The code might be pretty straight forward for someone who’s familiar with python and selenium, but if you are not sure about something you can look for explanation below. Also, if you are new to python world, I wrote a quick python setup on windows tutorial in which you can look into if you want to quickly setup python environment.
By the way, when I was writing this I encountered a number of new ideas where I could go with selenium and beautifulsoup combined together. Here’s a video example of how the script actually works:
* Install BeautifulSoup4 pip install beautifulsoup4
* Install win32api, win32con pip install pypiwin32
* Install selenium pip install selenium
* Include type_text.py in project’s folder
* Download and install Mozilla Firefox (some versions doesn’t work with selenium, I used 41.0.1)
* Use MousePos.exe to adjust coordinates if necessary
* Set your facebook user’s language to English (US)
Whole project can also be downloaded here
Continue reading “Add friends on facebook (python)”