Add friends on facebook (python)

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:

Requirements:
* 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)”

Invite friends to your facebook page with python (selenium)

Selenium is mostly used for writing test cases, but it can be used to automate repetitive actions on web. The selenium package itself doesn’t include a testing tool or framework, that’s why we’re going to use Python’s unittest module. If you haven’t got your python environment setup on windows already, here’s a tutorial on how to quickly setup python.

Requirements:
* 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 “Invite friends to your facebook page with python (selenium)”