Monday, October 30, 2017

Python : Making REST Requests on Android Phone with Python

Making REST Requests on Android Phone with Python

Make sure the phone is connected to the network

1. Install Termux app on your Android phone
2. Open Termux 
3. Enter "apt install python"
4. Enter "y" when asked
5. After installation enter "python" to check the ver details .
6. Type "exit()"
7. Repeat same for python2 and python3

Once done 
8. Enter "pip install requests" in your termux prompt to install "requests" library for python
9. Repeat commands "pip install json"  and "pip install urllib3"
10. Open python using command python or python2
11. Run command :
>>import requests
 r=requests.get("http://www.google.com")
print(r)
<Response [200]>


Python : Automation with python using Chrome

Automation with python using Chrome

1.Open cmd prompt
2. Cd C:\Python34\Scripts\easyinstall.exe selenium
3. After Installation goto
https://sites.google.com/a/chromium.org/chromedriver/downloads
4. Download the latest Driver
5. extract and place chrome driver in any directory
Ex : D:\Tools\python_automation\chromedriver_win32\chromedriver.exe

import os
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

#for i in range(1,50,1):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")

chromedriver = "D:\Tools\python_automation\chromedriver_win32\chromedriver.exe"

os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chrome_options)
driver.maximize_window()

driver.get("https://hide.me/en/proxy") #driver.get("https://whoer.net/webproxy")
driver.find_element_by_xpath("//div[@class='input-group']//input").send_keys("voting")
driver.find_element_by_xpath("//button").click()

driver.find_element_by_xpath("//div[@class='wp-polls-ans']//li//*[text()='waker']").click()
driver.find_element_by_xpath("//input[@name='vote']").click()