Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73416
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'failing': 0.07; 'hosts': 0.07; 'subject:support': 0.07; '*args,': 0.09; 'assuming': 0.09; 'name?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; '**kwargs)': 0.16; '**kwargs):': 0.16; 'hostname': 0.16; 'normally,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'urllib2,': 0.16; 'file,': 0.19; 'solution.': 0.20; 'seems': 0.21; 'import': 0.22; 'accepted.': 0.22; 'hack': 0.22; 'header:User-Agent:1': 0.23; 'script': 0.25; 'mention': 0.26; 'query': 0.26; 'this:': 0.26; 'subject:/': 0.26; 'required.': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'host': 0.29; 'generally': 0.29; "doesn't": 0.30; "i'm": 0.30; 'work.': 0.31; 'regular': 0.32; 'proceed': 0.33; "i'd": 0.34; 'could': 0.34; 'possible.': 0.35; 'something': 0.35; 'but': 0.35; 'version': 0.36; 'really': 0.36; 'should': 0.36; 'changing': 0.37; 'being': 0.38; 'skip:o 20': 0.38; 'server': 0.38; 'basis.': 0.38; 'easiest': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'rather': 0.38; 'that,': 0.38; 'does': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'according': 0.40; 'skip:u 10': 0.60; 'skip:o 30': 0.61; 'simply': 0.61; "you're": 0.61; 'back': 0.62; 'address': 0.63; 'different': 0.65; 'forward': 0.65; 'received:109': 0.72; 'forth': 0.81 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robin Becker <robin@reportlab.com> |
| Subject | Re: urllib/urllib2 support for specifying ip address |
| Date | Thu, 19 Jun 2014 12:51:39 +0100 |
| References | <53A2ABBB.3080907@chamonix.reportlab.co.uk> <CAPTjJmosrF1pKKEiLdPg_XOwmZMNMtgH13YipSxJWg-VZ9kAkg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 109.174.168.73 |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| In-Reply-To | <CAPTjJmosrF1pKKEiLdPg_XOwmZMNMtgH13YipSxJWg-VZ9kAkg@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11144.1403178715.18130.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1403178715 news.xs4all.nl 2841 [2001:888:2000:d::a6]:56909 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73416 |
Show key headers only | View raw
.......... > > Since you mention urllib2, I'm assuming this is Python 2.x, not 3.x. > The exact version may be significant. > I can use python >= 3.3 if required. > Can you simply query the server by IP address rather than host name? > According to the docs, urllib2.urlopen() doesn't check the > certificate, so it should be accepted. Or does the server insist on > the hostname being correct? > > Failing that, you could monkey-patch socket.create_connection, which > seems to be the thing that ultimately does the work. Something like > this: > > import socket. > orig_create_connection = socket.create_connection > def create_connection(address, *args, **kwargs): > if address == "domainA": address = "1.2.3.4" > return orig_create_connection(address, *args, **kwargs) > socket.create_connection = create_connection > # Proceed to use urllib2.urlopen() > > Untested, but may do what you want. > this seems like a way forward > Normally, though, I'd look at just changing the hosts file, if at all > possible. You're right that it does change state for your whole > computer, but it's generally the easiest solution. > > ChrisA > me too, but I want to start torturing from about 10 different servers so plumbum + a python script seems like a good choice and I would not really want to hack the hosts files back and forth on a regular basis. -- Robin Becker
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: urllib/urllib2 support for specifying ip address Robin Becker <robin@reportlab.com> - 2014-06-19 12:51 +0100
csiph-web