Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How Can I Combine These 2 Codes
#1
Firstly i'm sorry for my bad english. I tried to explain as clearly as possible. It's hard for me because it's not my main language sorry for that.


Okey so the source code that i want to change is this.

    import requests
    from bs4 import BeautifulSoup
    from random import choice    
    
    def GetProxy():
        Url = "https://sslproxies.org"
        R = requests.get(Url)
        Soup = BeautifulSoup(R.content, "html5lib")
        return {"https": choice(list(map(lambda x: x[0]+":"+x[1], list(zip(map(lambda x: x.text, Soup.find_all("td")[::8]), map(lambda x: x.text, Soup.find_all("td")[1::8]))))))}
    
    print(GetProxy())
    
    
    def UseProxy(Url):
        while True:
            try:
                Proxy = GetProxy()
                R = requests.get(Url, proxies=Proxy,
                                 timeout=5)
                if R.status_code == 200:
                    print("[+] Proxy Connect >> " + str(
                        Proxy))
                    break
                else:
                    print("[-] Connected To Proxy But Site İs Not Opened>> " + str(
                        Proxy))
            except:
                print("[-] Proxy Not Connect>> " + str(Proxy))
                pass
    
    
    Link = input("https://whatismyipaddress.com/tr/ip-im")
    UseProxy(Link)
I'm using this code for surfing with diffrent ip's. When i run this code its working and opening this website that is you see below code.

    Link = input("https://whatismyipaddress.com/tr/ip-im")
        UseProxy(Link)
But i want to do it with selenium thats why i did this changes in bellow marked with (----) but it didn't worked. Mozilla firefox did not opened.
    -------------------------------------------------------------------------
         from selenium import webdriver
    -----------------------------------------------------------------------
            import requests
            from bs4 import BeautifulSoup
            from random import choice
            ...
            ...
            ...
            ...
           --------------------------------------------------------------------------- 
            browser = webdriver.Firefox()
            browser.get("https://whatismyipaddress.com/tr/ip-im")
            -----------------------------------------------------------------------
            Link = input("https://whatismyipaddress.com/tr/ip-im")
            UseProxy(Link)
And then i puted these cods to up like you see in below.
    import requests
        from bs4 import BeautifulSoup
        from random import choice
        -------------------------------------------------------------------
         browser = webdriver.Firefox()
         browser.get("https://whatismyipaddress.com/tr/ip-im")
        -------------------------------------------------------------------------
        def GetProxy():
            Url = "https://sslproxies.org"
        ....
        ....
        ....
        ....
        ....
        ....
        ....
        ....
So my question is if where i put this codes it will work? Or what should i do to make it work?
snippsat write Oct-22-2020, 06:28 AM:
Added code tag in your post,look at BBCode on how to use.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020