-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnisb.py
54 lines (48 loc) · 1.61 KB
/
nisb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import requests
from bs4 import BeautifulSoup
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
import time
import pyautogui
#---------------------------BeautifulSoup--------------------------------#
r=requests.get("http://www.nisb.in")
soup=BeautifulSoup(r.text,'html.parser')
img=[]
img=soup.findAll("img",{"class":"img-thumbnail col-md-4"})
for link in img:
image=link.get("src")
imgname=os.path.split(image)[1]
qm=imgname.find("?")
imgname=imgname[:qm]
# r2=requests.get(image)
# with open(imgname,"wb") as f:
# f.write(r2.read)
# f.close()
print(imgname)
#---------------------------Selenium--------------------------------#
driver=webdriver.Firefox()
driver.get(image)
time.sleep(5)
actionChains = ActionChains(driver)
search=driver.find_element_by_xpath("/html/body/img")
actionChains.context_click(search).perform()
#---------------------------pyautogui--------------------------------#
pyautogui.FAILSAFE = True
pyautogui.typewrite(['down','down','down','enter'])
time.sleep(3)
pyautogui.moveTo(410,60,duration=2)
pyautogui.click(410,60)
location="C:\\users\\raish\\desktop\\python\\nisbinaug\\images"
pyautogui.typewrite(location,0.25)
time.sleep(2)
pyautogui.typewrite(['enter'])
time.sleep(3)
pyautogui.moveTo(895,570,duration=2)
pyautogui.click(895,570)
#pyautogui.typewrite(['enter'])
time.sleep(2)
#pyautogui.typewrite(['enter'])
driver.close()
time.sleep(2)