Hack Forums
[Python] Opening a url with a proxy - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Opening a url with a proxy (/showthread.php?tid=5977930)



Opening a url with a proxy - pms - Jun 8, 2019

first of, I'm fairly new to python so dont judge me please.
Questions -

[+] I already know how to open a url/link with python. But i want the link to run a proxy automaticly once i run the script. How?
[+] Is it even possible?


Code
#! /usr/bin/env python

import colored
from colored import stylize
import webbrowser

Continue = ''


# print(stylize('This is green', colored.fg('green')))


print('Welcome to this complex port scanner')
Continue = raw_input(('(') + stylize('+', colored.fg('green')) + (') Enter Website : '))
if Continue == Continue:
       webbrowser.open(Continue)



RE: Opening a url with a proxy - Lynx - Jun 9, 2019

You can use the 'requests' library with the proxy argument.
Code
import requests
proxies = {
   'http':'http://1.2.3.4:80',
   'https':'https://1.2.3.4:80'
}

requests.get('http://google.com', proxies=proxies)



RE: Opening a url with a proxy - pms - Jun 9, 2019

(Jun 9, 2019 01:14 AM)Lynx Wrote:  You can use the 'requests' library with the proxy argument.
Code
import requests
proxies = {
  'http':'http://1.2.3.4:80',
  'https':'https://1.2.3.4:80'
}

requests.get('http://google.com', proxies=proxies)

I would have to change the webbrowser.open to requests.get('http://google.com', proxies=proxies). right?


RE: Opening a url with a proxy - Lynx - Jun 9, 2019

(Jun 9, 2019 01:20 AM)pms Wrote:  I would have to change the webbrowser.open to requests.get('http://google.com', proxies=proxies). right?

Yes. Also, if you want to get the response, you can use this:

r = requests.get('http://google.com', proxies=proxies)
print(r.text)


RE: Opening a url with a proxy - pms - Jun 9, 2019

(Jun 9, 2019 01:25 AM)Lynx Wrote:  Yes. Also, if you want to get the response, you can use this:

r = requests.get('http://google.com', proxies=proxies)
print(r.text)

Got it, thank you for the help !