<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: ranaankur39</title>
    <description>The latest articles on Forem by ranaankur39 (@ranaankur39).</description>
    <link>https://forem.com/ranaankur39</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F365235%2F7871e761-8f69-4053-967d-89429f1542ab.png</url>
      <title>Forem: ranaankur39</title>
      <link>https://forem.com/ranaankur39</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ranaankur39"/>
    <language>en</language>
    <item>
      <title>Linkedin Bot (Web Automation Using Selenium)</title>
      <dc:creator>ranaankur39</dc:creator>
      <pubDate>Tue, 14 Apr 2020 08:52:31 +0000</pubDate>
      <link>https://forem.com/ranaankur39/linkedin-bot-web-automation-using-selenium-46ae</link>
      <guid>https://forem.com/ranaankur39/linkedin-bot-web-automation-using-selenium-46ae</guid>
      <description>&lt;p&gt;Hi, it's Ankur.&lt;/p&gt;

&lt;p&gt;This post is about powerful web automation library called Selenium and its implementation in python to login automatically into different famous social media sites.Sometimes its worth time taking to login everytime into your social media and remembering credentials. Web automation is one of the most hottest fields now a days used by a large scale of organization to automate their different processes.&lt;/p&gt;

&lt;p&gt;But for todays article we are considering only &lt;em&gt;Linkedin&lt;/em&gt; to get automatically logged into it with the help of web automation.&lt;/p&gt;

&lt;p&gt;Tools/libraries which are going to use are as follows&lt;br&gt;
&lt;strong&gt;python&lt;/strong&gt;,&lt;strong&gt;selenium&lt;/strong&gt;,&lt;strong&gt;time&lt;/strong&gt;,&lt;strong&gt;chrome driver&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Follow the following Steps to start
&lt;/h3&gt;

&lt;p&gt;1.Download Chrome webdriver to enable Selenium to connect with your browser.&lt;br&gt;
2.GOTO &lt;a href="http://chromedriver.chromium.org/downloads"&gt;http://chromedriver.chromium.org/downloads&lt;/a&gt;&lt;br&gt;
3.Downlaod the required version of Webdriver according to your Browser Version&lt;br&gt;
4.Now extract the downloaded zip file and copy the .exe file to the Python main directory&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's Start Coding
&lt;/h2&gt;

&lt;p&gt;a. Create a Linkedin.py file&lt;br&gt;
b. import the libraries (&lt;em&gt;Assuming you have already installed the above mentioned libraries&lt;/em&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import &lt;span class="nb"&gt;time&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;c. Make a class named as Linkedin and make a function inside it that takes your &lt;em&gt;username&lt;/em&gt;,&lt;em&gt;password&lt;/em&gt; as arguement to login.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;class Linkedin:
    def __init__&lt;span class="o"&gt;(&lt;/span&gt;self,username,password&lt;span class="o"&gt;)&lt;/span&gt;:
        self.username&lt;span class="o"&gt;=&lt;/span&gt;username
        self.password&lt;span class="o"&gt;=&lt;/span&gt;password
        self.bot&lt;span class="o"&gt;=&lt;/span&gt;webdriver.Chrome&lt;span class="o"&gt;(&lt;/span&gt;PATH_TO_BROWSER_DRIVER&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Give path of your chrome driver in &lt;em&gt;webdriver.chrome&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;d. Make a function inside the same class named as login&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt; def login&lt;span class="o"&gt;(&lt;/span&gt;self&lt;span class="o"&gt;)&lt;/span&gt;:
        &lt;span class="nv"&gt;bot&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;self.bot
        bot.get&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://www.linkedin.com/uas/login"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        time.sleep&lt;span class="o"&gt;(&lt;/span&gt;3&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="nv"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;bot.find_element_by_id&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"username"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        email.send_keys&lt;span class="o"&gt;(&lt;/span&gt;self.username&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="nv"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;bot.find_element_by_id&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"password"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        password.send_keys&lt;span class="o"&gt;(&lt;/span&gt;self.password&lt;span class="o"&gt;)&lt;/span&gt;
        time.sleep&lt;span class="o"&gt;(&lt;/span&gt;3&lt;span class="o"&gt;)&lt;/span&gt;
        password.send_keys&lt;span class="o"&gt;(&lt;/span&gt;Keys.RETURN&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here &lt;em&gt;bot.get&lt;/em&gt; will get the url of linkedin and after 3 second bot will find element by id "username" where it will fill your provided username.similarly for password it does same.&lt;/p&gt;

&lt;p&gt;e. Now call the above class and press login&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;load&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Linkedin&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"your_email"&lt;/span&gt;,&lt;span class="s2"&gt;"your_password"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
load.login&lt;span class="o"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;f. Now all done type the following command to execute&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 Linkedin.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;similarly you can use the same concept to auto login into several social media account.&lt;/p&gt;

&lt;p&gt;I hope this article will help people who want to learn about web automation.&lt;br&gt;
And I hope the dev.to community grows more!&lt;/p&gt;

</description>
      <category>python</category>
      <category>time</category>
      <category>selenium</category>
    </item>
  </channel>
</rss>
