NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import time
from pyvirtualdisplay import Display
import selenium.webdriver.common.keys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from datetime import datetime
from selenium.common.exceptions import NoSuchElementException
import getpass
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.proxy import Proxy, ProxyType


display = Display(visible=0, size=(800, 600))
display.start()

options = webdriver.FirefoxOptions()
options.log.level = "trace"
options.headless = True

#options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_argument('disable-infobars')

options.add_argument("--headless")
options.add_argument("--disable-gpu")
options.add_argument("--disable-extensions")
options.add_argument("--no-sandbox")
options.add_argument("--window-size=800,600")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-xss-auditor")
options.add_argument("--disable-web-security")
options.add_argument("--user-data-dir=/home/cekilisyap/userdata")
options.add_argument("--allow-running-insecure-content")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--disable-webgl")
options.add_argument("--disable-popup-blocking")

mobile_emulation = {"deviceName": "iPhone 5/SE"}
#options.add_argument("mobileEmulation", mobile_emulation)
options.add_argument("disable-infobars")

#options.add_experimental_option("useAutomationExtension", False)

user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"

options.add_argument("user-agent="+user_agent)


myProxy = "196.19.49.205:8800"

proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': '' # set this value as desired
})



capabilities = webdriver.DesiredCapabilities.FIREFOX
capabilities["marionette"] = True


capabilities = {
'browserName': 'firefox',
'marionette': True,
'firefoxOptions': {
'useAutomationExtension': False,
'marionette': True,
'realMobile': True,
'os_version': '14.0',
'excludeSwitches': ['enable-automation'],
'args': ['--start-maximized', '--disable-infobars']
}
}





#/usr/local/lib/python3.8/dist-packages/selenium/webdriver/firefox
driver = webdriver.Firefox(options=options, proxy=proxy, desired_capabilities=capabilities, log_path='/var/log/geckodriver.log')

driver.implicitly_wait(5)
driver.set_page_load_timeout(5)
driver.set_script_timeout(5)

driver.get("https://www.instagram.com/accounts/login/?hl=tr")
#driver.get("https://iplocation.com/")
print(driver.page_source)
#cookie = driver.find_element_by_xpath("//*[@id='react-root']/section/main/article/div/div/div/div[3]/button[1]")
#cookie.click()

username = WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='username']")))
password = WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='password']")))

username.clear()
username.send_keys("resitgalip")
password.clear()
password.send_keys("On.271982.?")

time.sleep(3)
password.send_keys(selenium.webdriver.common.keys.Keys.ENTER)

# Login_button = WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()


not_now = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//button[contains(text(), "Not Now")]'))).click()



#get url
driver.get("https://www.instagram.com/p/CPoB1sfgdLN/comments/")
time.sleep(3)

try:
driver.execute_script("document.querySelector('.XQXOT > div').remove();")
except:
print("Js Hata")


i = 0
start = datetime.now()

cssload = "dCJp8"
loadMoreBtn = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CLASS_NAME, cssload)))

#loadMoreBtn = driver.find_element_by_class_name(cssload)
i = 1
j=0
try:
while i>0:
loadMoreBtn.click()
time.sleep(1)
yorums = driver.find_elements_by_class_name("gElp9")

#if len(yorums) < 2:
# break

mylist = []
for n in yorums:
j = j+1
yorum = n.find_element_by_css_selector("div.C4VMK > span")
print(yorum.text)
mylist.append(yorum.text)
driver.execute_script("var liElements = document.querySelectorAll('.Mr508'); if (liElements.length > 0) { for (i = 0; i < liElements.length; i++) { liElements[i].remove();}}")

try:
loadMoreBtn = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CLASS_NAME, cssload)))
except NoSuchElementException:
print("Load Bulunamadı")
break

except Exception as e:
print("Hata : "+str(e))

driver.close();

end = datetime.now()
print("Başlangıç : "+start.strftime("%m/%d/%Y, %H:%M:%S"))
print("Bitiş : "+end.strftime("%m/%d/%Y, %H:%M:%S"))
print("Toplam "+str(j))
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.