rootviii / proxy_requests Goto Github PK
View Code? Open in Web Editor NEWa class that uses scraped proxies to make http GET/POST requests (Python requests)
License: MIT License
a class that uses scraped proxies to make http GET/POST requests (Python requests)
License: MIT License
I'm not able to get the status code and proxy IP which is used. Its printing blank lines.
Thanks for providing this great script! I was about to make something similar before finding this.
I had two things I noticed when using the code; ReadTimeout was not in the list of errors
and it could be a good idea to run a check if the returned data is not a cloudflare captcha check
I've added this bit of code to on my side and seems to do the job well;
(Added to the set_request_data function)
if "why_captcha_headline" in req.text:
raise CloudFlareCaptcha
then created a CloudFlareCaptcha exception class, and added it to the list of errors.
When this error is hit, it should hit the exception in each of the get/post functions, and then re-try
Rather a question than an issue: I have read that you have reduced the size of sockets to be parsed from sslproxies. I'm curios why as I first thought that the regex was faulty.
Hi, there!
Is it possible to get a body of response not to file but into a variable?
This way we could choose only to connect to 'elite proxy', or 'last checked' < 15 minutes etc.
Sorry my actual URL is 'https://yts.lt/'
Originally posted by @Pechi77 in #9 (comment)
Example code I was running:
r = ProxyRequests('https://www.google.com')
print(r.get())
None
Any suggestions?
I am trying to scrap a site which is blocked by my isp.
my code
from proxy_requests import ProxyRequests
r = ProxyRequests(url)
r.get()
output
Unable to make proxied request... Please check the validity of https://httpbin.org/ip
Hello, I am getting this message:
Unable to make proxied request... Please check the validity of https://graph.facebook.com/?id=https://www.ilpost.it/flashes/video-foto-gruppo-berlino&fields=og_object{engagement}
However, when I check it, the link is fine.
When I print out the proxy used, what I get is blank.
It seems to work only when I set the headers.
It modifies text body into a json body
if I want to send this in the body
something=somethingelse
it sends
"something=somethingelse"
Which breaks certain websites
Python 3.9.1 (default, Dec 13 2020, 11:55:53)
from proxy_requests import ProxyRequests
url = "https://api.ipify.org/"
r = ProxyRequests(url)
print(r)
--------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-9-c6b8a6a9416b> in <module>
----> 1 print(r)
~/.local/lib/python3.9/site-packages/proxy_requests/proxy_requests.py in __str__(self)
202
203 def __str__(self):
--> 204 return str(self.rdata['request'])
205
206
KeyError: 'request'
It is crucial to have UserAgent headers for some sites to work. I spend an hour debugging and trying to find what's wrong and it turned out that there is no get method with headers support
def get_with_headers(self):
if len(self.sockets) > 0:
current_socket = self.sockets.pop(0)
proxies = {"http": "http://" + current_socket, "https": "https://" + current_socket}
try:
request = requests.get(self.url, timeout=3.0, proxies=proxies, headers=self.headers)
self.request = request.text
self.headers = request.headers
self.status_code = request.status_code
self.proxy_used = current_socket
except:
print('working...')
self.get_with_headers()
is there a way to use every proxy once?
my code is like:
`
from proxy_requests import ProxyRequests
while True:
r = ProxyRequests("Censored")
r.post({"Censored"})
print(r)
print(r.get_status_code())
print(r.get_proxy_used())`
and output is like this:
`
91.92.80.25:40487
"CENSORED"
200
117.206.83.26:41960
"CENSORED"
400
117.206.83.26:41960
"CENSORED"
400
117.206.83.26:41960
"CENSORED"`
I've noticed that if I 10 times call ProxyRequest I get always the same first proxy from the list. Is it possible to get a random proxy from the list?
Not Working On Recent Python Version 3.9
It Do Request then reply with error
Proxy Pool Empty
and dont use no proxy no return source no json
There are proxies in the list which are http only, and I am assuming they get skipped.
It's better to ignore the http proxies or add support for them so that they are not skipped.
Pass extra data to request get
for example
data = {'key': 1 , "key2":2}
r = ProxyRequests(url)
r.set_headers(headers)
r.get_with_headers()
r.get(data)
Hi,
I am missing the possibility to get the responsed url like response.request.url in Python’s Requests Library. I can't find this info in headers or html.text.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.