Python Forum
Curl with source ip- pycurl
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curl with source ip- pycurl
#1
Hello Folks
i have a sever with about 1000 ip addresses
and i want to check the external ip address using different source ip for each curl command .

in linux bash i can do that using :

curl --interface 1.1.1.1 ifconfig.io --max-time 2
curl --interface 2.2.2.2 ifconfig.io --max-time 2


above result of bash is only 1 line with ip
but in python the result of curl is an html full content , so not sure how to let pycurl be as bash curl .

also i googled a lot couldnt find a way to inject source ip in python for each curl request .

import pycurl
from StringIO import StringIO

buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://ifconfig.io/')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()

body = buffer.getvalue()
# Body is a string in some encoding.
# In Python 2, we can print it without knowing what the encoding is.
print(body)



above is ok , but as i said it has two issues :
1- result is full html page not as linux curl
2- i cant know where to put option as source ip address as my server is getting many ips


hopefully help me out !

thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with Button press/curl Imbatech 2 2,084 Apr-02-2020, 02:37 PM
Last Post: Imbatech

Forum Jump:

User Panel Messages

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