Skip to content

Instantly share code, notes, and snippets.

@vaibhavkumar049
Last active July 3, 2020 05:10
Show Gist options
  • Save vaibhavkumar049/e970d5ac5207f4ac87f7e2888d343523 to your computer and use it in GitHub Desktop.
Save vaibhavkumar049/e970d5ac5207f4ac87f7e2888d343523 to your computer and use it in GitHub Desktop.
rekhta website screen shot
import time
from selenium import webdriver
# Do not use this without their permission
# change website url
# chnage saving location in line 32
# change email/password
# change range in line 20 according to your book length
# start my code
from selenium.common.exceptions import NoSuchElementException
url = 'https://www.rekhta.org/ebooks/tahreek-e-azadi-mein-bihar-ke-musalmanon-ka-hissa-taqi-raheem-ebooks'
path = '/home/vaibhav/MyCode/take-screenshot/scrape.png'
driver = webdriver.Chrome()
driver.set_window_size(1920, 1080)
driver.get(url)
# el = driver.find_element_by_tag_name('body')
for i in range(620):
try:
login_el=driver.find_element_by_link_text('LOG IN')
login_el.click()
email_el = driver.find_element_by_id("Email")
email_el.send_keys("replace it wiht your email")
password_el = driver.find_element_by_id("Password")
password_el.send_keys("replace it with your password")
loginBtn_el = driver.find_element_by_id("BtnWrldLogin")
loginBtn_el.click()
time.sleep(2)
except NoSuchElementException:
el = driver.find_element_by_id("activeAfterZoom")
el.screenshot('/home/vaibhav/MyCode/take-screenshot/scrape'+str(i)+'.png')
btn = driver.find_element_by_xpath('//a[@class="left pull-left ebookprev"]')
btn.click()
time.sleep(2)
# el = driver.find_element_by_id("activeAfterZoom")
# el.screenshot('/home/vaibhav/MyCode/take-screenshot/scrape2.png')
# driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment