Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
5.7 kB
5
Indexable
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import time
import os
import warnings

warnings.filterwarnings("ignore")


# PROGRAM IS TEST WIHT DUMMY DATA

class Scraper:
    def Setup(self):
        options = Options()
        options.add_argument("--log-level=3")
        options.add_argument("--start-maximized")
        options.add_experimental_option("debuggerAddress", "127.0.0.1:9202")

        self.driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)


    def Remote_signal(self):
        os.popen("chrome.exe --remote-debugging-port=9202 --user-data-dir=\"C:\selenum\ChromeProfile\"")


    def File_reading(self):
        f = open("urls.txt", "r")
        self.urls = f.readlines()
        self.urls = [x.strip() for x in self.urls]


    def Automate(self):

        if True:

            self.driver.get("https://support.google.com/legal/contact/lr_counternotice?product=websearch&utm_source=wnc_594600&utm_medium=gamma&utm_campaign=wnc_594600&utm_content=msg_638303&hl=en-KE")

            # Country of Residence
            country = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@class='sc-select']"))).click()
            time.sleep(2)
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//li[contains(text(),'Belize')]"))).click()
            time.sleep(2)
            # Full name
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='full_name']"))).send_keys("Emily Stone")

            # Your Title
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='your_title']"))).send_keys("Designated DMCA Agent")

            # Company Name
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='companyname']"))).send_keys("nothing")

            # Contact Email
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='contact_email_noprefill']"))).clear()
            time.sleep(1.5)
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='contact_email_noprefill']"))).send_keys("dmca@xxbrits.com")

            # Address
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//textarea[@name='address']"))).send_keys("Equity House
84 Albert Street, P.O. Box 617
Belize City, Belize
Central America")

            # Phone Number
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='phone']"))).send_keys("07761732677")

            # URL OF THE CONTENT in Question
            
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='material_location']"))).send_keys(self.urls[0])
            del self.urls[0]

            ik = 2
            for url in self.urls:
                WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//*[contains(text(),'Add additional field')]"))).click()
                time.sleep(.5)
                WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, f"//input[@aria-label='URL(s) of the content in question {ik}']"))).send_keys(url)
                ik += 1

            # Choose Radio Button
            # find by text
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//*[contains(text(),'I am the owner of the content')]"))).click()

            # More details
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//textarea[@name='dmca_clarifications']"))).send_keys("Hey there. As the Designated DMCA Agent of https://shemale6.com, I understand that content creators may wish to have their videos removed from our website, and we are working diligently to improve our approach in this regard. While we do encourage content creators to file DMCA requests for videos they own, it's important to keep in mind that they don't have ownership over specific search queries or a specific section of our website. I hope this makes sense, and I kindly ask that you remove it from your list. Thanks. Sincerely, Peter Maina")

            #Tick To COnfirm
            we = WebDriverWait(self.driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, "//*[contains(text(),'Tick to confirm')]")))
            for i in we:
                i.click()

            # Signatures
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@name='signature']"))).send_keys("Emily Stone")

            time.sleep(2)
            
            input("Press Enter to continue...")
            
            # Submit
            #WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//button[@class='submit-button material2-button material2-button--filled']"))).click()

            time.sleep(5)


if __name__ == "__main__":
    scraper = Scraper()
    scraper.Remote_signal()
    scraper.Setup()
    scraper.File_reading()
    scraper.Automate()