-
Notifications
You must be signed in to change notification settings - Fork 0
/
goog.txt
1420 lines (1380 loc) · 106 KB
/
goog.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
b'<!DOCTYPE html>\r
<html itemscope itemtype="http://schema.org/QAPage">\r
\r
<head>\r
\r
<title>authentication - Python: urllib2.HTTPError: HTTP Error 401: Unauthorized - Stack Overflow</title>\r
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">\r
<link rel="apple-touch-icon image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">\r
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">\r
\r
\r
<meta property="og:type" content="website"/>\r
<meta property="og:url" content="https://stackoverflow.com/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized"/>\r
<meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]?v=73d79a89bded" />\r
<meta name="twitter:card" content="summary"/>\r
<meta name="twitter:domain" content="stackoverflow.com"/>\r
<meta name="twitter:title" property="og:title" itemprop="title name" content="Python: urllib2.HTTPError: HTTP Error 401: Unauthorized" />\r
<meta name="twitter:description" property="og:description" itemprop="description" content="I was trying to load a web page, but I ran into this problem. I do have the username and password, but I don't know how to use them in python code. I looked up on python tutorial, and this is what I " />\r
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>\r
<script src="https://cdn.sstatic.net/Js/stub.en.js?v=1e7aa62d9679"></script>\r
\r
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/all.css?v=abaeac34fef4">\r
\r
<link rel="alternate" type="application/atom+xml" title="Feed for question 'Python: urllib2.HTTPError: HTTP Error 401: Unauthorized'" href="/feeds/question/10195915">\r
<meta name="twitter:app:country" content="US" />\r
<meta name="twitter:app:name:iphone" content="Stack Exchange iOS" />\r
<meta name="twitter:app:id:iphone" content="871299723" />\r
<meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized" />\r
<meta name="twitter:app:name:ipad" content="Stack Exchange iOS" />\r
<meta name="twitter:app:id:ipad" content="871299723" />\r
<meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized" />\r
<meta name="twitter:app:name:googleplay" content="Stack Exchange Android">\r
<meta name="twitter:app:url:googleplay" content="http://stackoverflow.com/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized">\r
<meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">\r
<script>\r
\r
StackExchange.ready(function () {\r
\r
StackExchange.using("snippets", function () {\r
StackExchange.snippets.initSnippetRenderer();\r
});\r
\r
\r
StackExchange.using("postValidation", function () {\r
StackExchange.postValidation.initOnBlurAndSubmit($(\'#post-form\'), 2, \'answer\');\r
});\r
\r
\r
StackExchange.question.init({showAnswerHelp:true,totalCommentCount:0,shownCommentCount:0,highlightColor:\'#F4A83D\',backgroundColor:\'#FFF\',questionId:10195915});\r
\r
styleCode();\r
\r
StackExchange.realtime.subscribeToQuestion(\'1\', \'10195915\');\r
StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks(\'#content\', \'.post-text\'); });\r
\r
});\r
</script>\r
\r
\r
\r
\r
\r
\r
\r
\r
\r
<script>\r
StackExchange.init({"locale":"en","serverTime":1514953728,"routeName":"Questions/Show","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","recaptchaAudioLang":"en","enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"childUrl":"https://meta.stackoverflow.com","enableSocialMediaInSharePopup":true,"protocol":"https"},"user":{"fkey":"11a5d05d53ee3d8ae156544f3b2db468","tid":"2b3e93e2-a98c-37a1-d39b-1cb99c825283","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true,"canSeeNewHeaderDesign":true,"ab":{"job_search_status":{"v":"required_job_status_no_default_2","g":1}}},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}},"story":{"minCompleteBodyLength":75,"likedTagsMaxLength":300,"dislikedTagsMaxLength":300},"jobPreferences":{"maxNumDeveloperRoles":2,"maxNumIndustries":4}}, {"site":{"allowImageUploads":true,"enableUserHovercards":true,"styleCode":true,"enableImgurHttps":true,"forceHttpsImages":true},"comments":{},"userProfile":{"openGraphAPIKey":"58740831ad23540e00c58987"},"tags":{},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true},"flags":{"allowRetractingFlags":true},"topBar":{"showNewFeatureNotice":true},"snippets":{"snippetsEnabled":true,"renderDomain":"stacksnippets.net"},"paths":{},"markdown":{"asteriskIntraWordEmphasis":true},"monitoring":{"clientTimingsAbsoluteTimeout":30000,"clientTimingsDebounceTimeout":1000}});\r
StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"f553069af1e2","js/moderator.en.js":"1dabe11581c9","js/full-anon.en.js":"c7592795cb21","js/full.en.js":"ca0e1c29582a","js/wmd.en.js":"8626b08bd666","js/third-party/jquery.autocomplete.min.js":"d3b8fa7fdf74","js/third-party/jquery.autocomplete.min.en.js":"","js/mobile.en.js":"9ff76b90df3a","js/help.en.js":"26fed267aae8","js/tageditor.en.js":"9ce96385bbcc","js/tageditornew.en.js":"92ef81a67497","js/inline-tag-editing.en.js":"e7aa31e8eba1","js/revisions.en.js":"d059a98114ef","js/review.en.js":"b8a03302e1c8","js/tagsuggestions.en.js":"ddb0e41afe26","js/post-validation.en.js":"06a039087eb5","js/explore-qlist.en.js":"e71f14781288","js/events.en.js":"e406f3fc9554","js/keyboard-shortcuts.en.js":"90f5228ac4e2","js/external-editor.en.js":"3e5baf662544","js/adops.en.js":"9a6a7812a212","js/external-editor.en.js":"3e5baf662544","js/snippet-javascript.en.js":"a73dc08b2b76","js/snippet-javascript-codemirror.en.js":"b3d85eb33707"});\r
StackExchange.using("gps", function() {\r
StackExchange.gps.init(true);\r
});\r
</script>\r
<noscript id="noscript-css"><style>body,.top-bar{margin-top:1.9em}</style></noscript>\r
</head>\r
<body class="question-page new-topbar">\r
<script async src="https://js-sec.indexww.com/ht/p/185901-159836282584097.js"></script>\r
\r
<div id="notify-container"></div>\r
<div id="custom-header"></div>\r
<header class="top-bar js-top-bar _fixed">
<div class="-container">
<div class="-main">
<a href="https://stackoverflow.com" class="-logo js-gps-track"
data-gps-track="top_nav.click({is_current:false, location:2, destination:8})">
<span class="-img">Stack Overflow</span>
</a>
<nav class="navigation" role="navigation" aria-label="site navigation">
<ol class="-list">
<li class="-item _current">
<a id="nav-questions" href="/questions" class="-link js-gps-track"
data-gps-track="top_nav.click({is_current:true, location:2, destination:1})">Questions</a>
</li>
<li class="-item">
<a id="nav-jobs" href="/jobs?med=site-ui&ref=jobs-tab" class="-link js-gps-track"
data-gps-track="top_nav.click({is_current:false, location:2, destination:6})">Developer Jobs</a>
</li>
<li class="-item">
<a id="nav-tags" href="/tags" class="-link js-gps-track"
data-gps-track="top_nav.click({is_current:false, location:2, destination:2})">Tags</a>
</li>
<li class="-item">
<a id="nav-users" href="/users" class="-link js-gps-track"
data-gps-track="top_nav.click({is_current:false, location:2, destination:3})">Users</a>
</li>
</ol>
</nav>
</div>
<form id="search" action="/search" method="get" class="searchbar" autocomplete="off" role="search">
<input name="q" type="text" placeholder="Search\xe2\x80\xa6" value="" tabindex="1" autocomplete="off" maxlength="240" class="f-input js-search-field" />
<button type="submit" aria-label="Search..." class="btn-topbar-primary js-search-submit"><svg aria-hidden="true" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="M12.86 11.32L18 16.5 16.5 18l-5.18-5.14v-.35a7 7 0 1 1 1.19-1.19h.35zM7 12A5 5 0 1 0 7 2a5 5 0 0 0 0 10z"/></svg></button>
</form>
<div class="-actions">
<nav class="secondary-nav">
<div class="-dialog-container js-topbar-dialog-corral">
\r
\r
<div class="topbar-dialog siteSwitcher-dialog dno">\r
<div class="header">\r
<h3><a href="https://stackoverflow.com">current community</a>\r
</h3>\r
</div>\r
<div class="modal-content current-site-container">\r
<ul class="current-site">\r
<li>\r
<div class="related-links">\r
<a href="https://stackoverflow.com/help" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:14 })"\r
>help</a>\r
<a href="https://chat.stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })"\r
>chat</a>\r
</div>\r
<a href="https://stackoverflow.com"\r
class="current-site-link site-link js-gps-track"\r
data-id="1"\r
data-gps-track="site_switcher.click({ item_type:3 })">\r
<div class="favicon favicon-stackoverflow site-icon" title="Stack Overflow"></div>\r
Stack Overflow\r
</a>\r
\r
</li>\r
<li class="related-site">\r
<div class="L-shaped-icon-container">\r
<span class="L-shaped-icon"></span>\r
</div>\r
\r
<a href="https://meta.stackoverflow.com"\r
class="site-link js-gps-track"\r
data-id="552"\r
data-gps-track="site.switch({ target_site:552, item_type:3 }),site_switcher.click({ item_type:4 })">\r
<div class="favicon favicon-stackoverflowmeta site-icon" title="Meta Stack Overflow"></div>\r
Meta Stack Overflow\r
</a>\r
\r
</li>\r
</ul>\r
</div>\r
\r
<div class="header" id="your-communities-header">\r
<h3>\r
your communities </h3>\r
\r
</div>\r
<div class="modal-content" id="your-communities-section">\r
\r
<div class="call-to-login">\r
<a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=%2fusers%2fstory%2fcurrent&amp;utm_source=stackoverflow.com&amp;utm_medium=dev-story&amp;utm_campaign=signup-redirect" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })"\r
>Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f10195915%2fpython-urllib2-httperror-http-error-401-unauthorized" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })"\r
>log in</a> to customize your list.\r
</div>\r
</div>\r
\r
<div class="header">\r
<h3><a href="https://stackexchange.com/sites">more stack exchange communities</a>\r
</h3>\r
<a href="https://stackoverflow.blog" class="fr">company blog</a>\r
</div>\r
<div class="modal-content">\r
<div class="child-content"></div>\r
</div> \r
</div>\r
<div class="topbar-dialog help-dialog js-help-dialog dno">
<div class="modal-content">
<ul>
<li>
<a href="/tour" class="js-gps-track" data-gps-track="help_popup.click({ item_type:1 })">
Tour
<span class="item-summary">
Start here for a quick overview of the site
</span>
</a>
</li>
<li>
<a href="/help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:4 })">
Help Center
<span class="item-summary">
Detailed answers to any questions you might have
</span>
</a>
</li>
<li>
<a href="https://meta.stackoverflow.com" class="js-gps-track" data-gps-track="help_popup.click({ item_type:2 })">
Meta
<span class="item-summary">
Discuss the workings and policies of this site
</span>
</a>
</li>
<li>
<a href="https://stackoverflow.com/company/about" class="js-gps-track" data-gps-track="help_popup.click({ item_type:6 })">
About Us
<span class="item-summary">
Learn more about Stack Overflow the company
</span>
</a>
</li>
<li>
<a href="https://www.stackoverflowbusiness.com/?ref=topbar_help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:7 })">
Business
<span class="item-summary">
Learn more about hiring developers or posting ads with us
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
<ol class="-list">
<li class="-item">
<a href="https://stackexchange.com/users/?tab=inbox" class="-link js-inbox-button" title="Recent inbox messages">
<svg aria-hidden="true" class="svg-icon iconInbox" width="20" height="18" viewBox="0 0 20 18"><path d="M15.19 1H4.63c-.85 0-1.6.54-1.85 1.35L0 10.79V15c0 1.1.9 2 2 2h16a2 2 0 0 0 2-2v-4.21l-2.87-8.44A2 2 0 0 0 15.19 1zm-.28 10l-2 2h-6l-2-2H1.96L4.4 3.68A1 1 0 0 1 5.35 3h9.12a1 1 0 0 1 .95.68L17.86 11h-2.95z"/></svg>
<span class="indicator-badge js-unread-count _important" style="display: none;"></span>
</a>
</li>
<li class="-item">
<a href="https://stackexchange.com/users/?tab=reputation" class="-link js-achievements-button" title="Recent achievements: reputation, badges, and privileges earned" data-unread-class="_highlighted-positive">
<svg aria-hidden="true" class="svg-icon iconAchievements" width="18" height="18" viewBox="0 0 18 18"><path d="M15 2V1H3v1H0v4c0 1.6 1.4 3 3 3v1c.4 1.5 3 2.6 5 3v2H5s-1 1.5-1 2h10c0-.4-1-2-1-2h-3v-2c2-.4 4.6-1.5 5-3V9c1.6-.2 3-1.4 3-3V2h-3zM3 7c-.5 0-1-.5-1-1V4h1v3zm8.4 2.5L9 8 6.6 9.4l1-2.7L5 5h3l1-2.7L10 5h2.8l-2.3 1.8 1 2.7h-.1zM16 6c0 .5-.5 1-1 1V4h1v2z"/></svg>
<span class="indicator-badge js-unread-count _positive" style="display: none;"></span>
</a>
</li>
<li class="-item"><a href="#" class="-link js-help-button" title="Help Center and other resources">
<svg aria-hidden="true" class="svg-icon iconHelp" width="18" height="18" viewBox="0 0 18 18"><path d="M9 1a8 8 0 1 0 0 16A8 8 0 0 0 9 1zm.81 12.13c-.02.71-.55 1.15-1.24 1.13-.66-.02-1.17-.49-1.15-1.2.02-.72.56-1.18 1.22-1.16.7.03 1.2.51 1.17 1.23zM11.77 8a5.8 5.8 0 0 1-1.02.91l-.53.37c-.26.2-.42.43-.5.69a4 4 0 0 0-.09.75c0 .05-.03.16-.18.16H7.88c-.16 0-.18-.1-.18-.15.03-.66.12-1.21.4-1.66a5.29 5.29 0 0 1 1.43-1.22c.16-.12.28-.25.38-.39a1.34 1.34 0 0 0 .02-1.71c-.24-.31-.51-.46-1.03-.46-.51 0-.8.26-1.02.6-.21.33-.18.73-.18 1.1H5.75c0-1.38.35-2.25 1.1-2.76.52-.35 1.17-.5 1.93-.5 1 0 1.79.18 2.49.71.64.5.98 1.18.98 2.12 0 .57-.2 1.05-.48 1.44z"/></svg>
</a></li>
<li class="-item">
<a href="https://stackexchange.com" class="-link js-site-switcher-button js-gps-track" data-gps-track="site_switcher.show" title="A list of all 171 Stack Exchange sites">
<svg aria-hidden="true" class="svg-icon iconStackExchange" width="18" height="18" viewBox="0 0 18 18"><path d="M1 13c0 1.1.9 2 2 2h8v3l3-3h1a2 2 0 0 0 2-2v-2H1v2zM15 1H3a2 2 0 0 0-2 2v2h16V3a2 2 0 0 0-2-2zM1 6h16v4H1V6z"/></svg>
</a>
</li>
</ol>
</nav>
<div class="-ctas">
<a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f10195915%2fpython-urllib2-httperror-http-error-401-unauthorized" class="login-link btn-clear" rel="nofollow">Log In</a>
<a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2fusers%2fstory%2fcurrent&utm_source=stackoverflow.com&utm_medium=dev-story&utm_campaign=signup-redirect" class="login-link btn-topbar-primary" rel="nofollow">Sign Up</a>
</div>
</div>
</div>
</header>
<script>
StackExchange.ready(function() { StackExchange.topbar.init(); });
StackExchange.scrollPadding.setPaddingTop(60, 10); </script>
\r
\r
\r
<div class="container _full ">\r
\r
\r
\r
<div id="content" class="snippet-hidden">\r
\r
\r
\r
\r
<div itemscope itemtype="http://schema.org/Question">\r
<link itemprop="image" href="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">\r
\r
\r
<div class="s-hero hero-container _fixed js-dismissable-hero" data-campaign-name="stk">
<div class="-container g-row jc-sp-between ai-center">
<div class="g-col6">
<p class="-title"><strong>Join Stack Overflow</strong> to learn, share knowledge, and build your career.</p>
</div>
<div class="s-signup _hero g-col6">
<div id="openid-buttons" class="-social">
<a class="btn-outlined -white _medium _block" href="/users/signup?ssrc=hero&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f10195915%2fpython-urllib2-httperror-http-error-401-unauthorized" rel="nofollow">Email Sign Up</a>
<span class="-or">or sign in with</span>
<div class="major-provider btn _block _medium _google" data-provider=\'google\' data-oauthserver=\'https://accounts.google.com/o/oauth2/auth\' data-oauthversion=\'2.0\'>
<svg aria-hidden="true" class="svg-icon native iconGoogle" width="18" height="18" viewBox="0 0 18 18"><g><path d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18z" fill="#4285F4"/><path d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17z" fill="#34A853"/><path d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18l2.67-2.07z" fill="#FBBC05"/><path d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.77 4.77 0 0 1 4.48-3.3z" fill="#EA4335"/></g></svg> Google
</div>
<div class="major-provider btn _block _medium _facebook" data-provider=\'facebook\' data-oauthserver=\'https://www.facebook.com/v2.0/dialog/oauth\' data-oauthversion=\'2.0\'>
<svg aria-hidden="true" class="svg-icon iconFacebook" width="18" height="18" viewBox="0 0 18 18"><path d="M1.88 1C1.4 1 1 1.4 1 1.88v14.24c0 .48.4.88.88.88h7.67v-6.2H7.46V8.4h2.09V6.61c0-2.07 1.26-3.2 3.1-3.2.88 0 1.64.07 1.87.1v2.16h-1.29c-1 0-1.19.48-1.19 1.18V8.4h2.39l-.31 2.42h-2.08V17h4.08c.48 0 .88-.4.88-.88V1.88c0-.48-.4-.88-.88-.88H1.88z" fill="#3C5A96"/></svg> Facebook
</div>
<a id="close" href="#" class="js-dismiss js-hero-mini-disabled -dismiss" title="dismiss"><svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41L13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9z"/></svg></a>
</div>
<form id="login-form" action="/users/signup?ssrc=hero&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f10195915%2fpython-urllib2-httperror-http-error-401-unauthorized" method="POST">
<input type="hidden" name="fkey" value="11a5d05d53ee3d8ae156544f3b2db468">
<input type="hidden" name="ssrc" value="" />
<input type="hidden" id="oauth_version" name="oauth_version" />
<input type="hidden" id="oauth_server" name="oauth_server" />
<div id="se-login-fields">
<input type="hidden" name="legalLinksShown" value="0" />
</div>
</form>
<script>
StackExchange.ready(function () {
StackExchange.InlineAuth.init();
})
</script>
</div>
</div>
</div><script>\r
StackExchange.ready(function () {\r
\r
StackExchange.Hero.init("stk", "a");\r
\r
var location = 0;\r
if ($("body").hasClass("questions-page")) {\r
location = 1;\r
} else if ($("body").hasClass("question-page")) {\r
location = 1;\r
} else if ($("body").hasClass("faq-page")) {\r
location = 5;\r
} else if ($("body").hasClass("home-page")) {\r
location = 3;\r
}\r
\r
$(\'#tell-me-more\').click(function () {\r
StackExchange.using("gps", function () {\r
StackExchange.gps.track("hero.action", { hero_action_type: \'cta\', location: location }, true);\r
});\r
});\r
\r
$(\'.js-dismissable-hero #close\').click(function () {\r
StackExchange.using("gps", function () {\r
StackExchange.gps.track("hero.action", { hero_action_type: "minimize", location: location }, true);\r
});\r
\r
StackExchange.Hero.dismiss();\r
\r
$.ajax({\r
url: "/hero-mini",\r
success: function (data) {\r
$(".js-dismissable-hero").fadeOut("fast", function () {\r
$(".js-dismissable-hero").replaceWith(data);\r
$("#herobox-mini").fadeIn("fast");\r
});\r
}\r
});\r
return false;\r
});\r
});
</script> <div class="inner-content">\r
<div id="question-header">\r
<h1 itemprop="name"><a href="/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized" class="question-hyperlink">Python: urllib2.HTTPError: HTTP Error 401: Unauthorized</a></h1>\r
\r
<div class="aside-cta" role="navigation" aria-label="ask new question">
<a href="/questions/ask" class="btn-outlined">Ask Question</a>
</div>
\r
</div>\r
<div id="mainbar" role="main" aria-label="question and answers">\r
\r
\r
\r
<div class="question" data-questionid="10195915" id="question">\r
\r
<div id="dfp-tlb" class="everyonelovesstackoverflow"></div> <table>\r
<tr>\r
<td class="votecell">\r
\r
\r
<div class="vote">\r
<input type="hidden" name="_id_" value="10195915">\r
<a class="vote-up-off" title="This question shows research effort; it is useful and clear">up vote</a>\r
<span itemprop="upvoteCount" class="vote-count-post ">7</span>\r
<a class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful">down vote</a>\r
\r
<a class="star-off" href="#">favorite</a>\r
<div class="favoritecount"><b>4</b></div>\r
\r
\r
</div>\r
\r
</td>\r
\r
<td class="postcell">\r
<div>\r
<div class="post-text" itemprop="text">\r
\r
<p>I was trying to load a web page, but I ran into this problem. I do have the username and password, but I don\'t know how to use them in python code. I looked up on python tutorial, and this is what I wrote:</p>
<pre><code>import urllib2
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
username = \'user\'
password = \'pass\'
top_level_url = "www.something.com:80"
password_mgr.add_password(None, top_level_url, username, password)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
opener.open(\'http://www.something.com/h/h.html\')
urllib2.install_opener(opener)
response = urllib2.urlopen()
page = response.read()
print page
</code></pre>
<p>Anything wrong?</p>
</div>\r
<div class="post-taglist">\r
<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/authentication" class="post-tag" title="show questions tagged 'authentication'" rel="tag">authentication</a> \r
</div>\r
<table class="fw">\r
<tr>\r
<td class="vt">\r
<div class="post-menu"><a href="/q/10195915" title="short permalink to this question" class="short-link" id="link-post-10195915">share</a><span class="lsep">|</span><a href="/posts/10195915/edit" class="suggest-edit-post" title="">improve this question</a></div> \r
</td>\r
<td align="right" class="post-signature">\r
<div class="user-info ">\r
<div class="user-action-time">\r
<a href="/posts/10195915/revisions" title="show all edits to this post">edited <span title="2012-04-17 17:44:27Z" class="relativetime">Apr 17 \'12 at 17:44</span></a>\r
</div>\r
<div class="user-gravatar32">\r
<a href="/users/243245/rup"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/aed5c13647d581ae231f019a886e05a8?s=32&d=identicon&r=PG" alt="" width="32" height="32"></div></a>\r
</div>\r
<div class="user-details">\r
<a href="/users/243245/rup">Rup</a>\r
<div class="-flair">\r
<span class="reputation-score" title="reputation score 24,669" dir="ltr">24.7k</span><span title="6 gold badges"><span class="badge1"></span><span class="badgecount">6</span></span><span title="58 silver badges"><span class="badge2"></span><span class="badgecount">58</span></span><span title="81 bronze badges"><span class="badge3"></span><span class="badgecount">81</span></span>\r
</div>\r
</div>\r
</div> </td>\r
<td class="post-signature owner">\r
<div class="user-info ">\r
<div class="user-action-time">\r
asked <span title="2012-04-17 17:18:28Z" class="relativetime">Apr 17 \'12 at 17:18</span>\r
</div>\r
<div class="user-gravatar32">\r
<a href="/users/1321087/stupidguy"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/840809390a780f85498f53c86877e122?s=32&d=identicon&r=PG" alt="" width="32" height="32"></div></a>\r
</div>\r
<div class="user-details">\r
<a href="/users/1321087/stupidguy">stupidguy</a>\r
<div class="-flair">\r
<span class="reputation-score" title="reputation score " dir="ltr">146</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="2 silver badges"><span class="badge2"></span><span class="badgecount">2</span></span><span title="8 bronze badges"><span class="badge3"></span><span class="badgecount">8</span></span>\r
</div>\r
</div>\r
</div>\r
</td>\r
</tr>\r
</table>\r
</div>\r
</td>\r
</tr>\r
\r
<tr>\r
<td class="votecell"></td>\r
<td>\r
\t <div id="comments-10195915" class="comments js-comments-container dno">\r
\t\t <table>\r
<tbody class="js-comments-list"\r
data-remaining-comments-count="0"\r
data-canpost="false"\r
data-cansee="true"\r
data-comments-unavailable="false"\r
data-addlink-disabled="true">\r
\r
<tr><td></td><td></td></tr>\r
</tbody>\r
\t\t </table>\r
\t </div>\r
\r
<div id="comments-link-10195915" data-rep=50 data-anon=true>\r
\r
<a class="js-add-link comments-link disabled-link "\r
title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments."\r
>add a comment</a><span class="js-link-separator dno"> | </span>\r
<a class="js-show-link comments-link dno" title="expand to show all comments on this post" href=# onclick=""></a>\r
</div> \r
</td>\r
</tr> </table>\r
</div>\r
\r
<div id="answers">\r
\r
<a name="tab-top"></a>\r
<div id="answers-header">\r
<div class="subheader answers-subheader">\r
<h2 data-answercount="2">\r
2 Answers\r
<span style="display:none;" itemprop="answerCount">2</span>\r
</h2>\r
<div>\r
<div id="tabs">\r
<a href="/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized?answertab=active#tab-top" data-nav-xhref="" title="Answers with the latest activity first" data-value="active" data-shortcut="A">\r
active</a>\r
<a href="/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized?answertab=oldest#tab-top" data-nav-xhref="" title="Answers in the order they were provided" data-value="oldest" data-shortcut="O">\r
oldest</a>\r
<a class="youarehere " href="/questions/10195915/python-urllib2-httperror-http-error-401-unauthorized?answertab=votes#tab-top" data-nav-xhref="" title="Answers with the highest score first" data-value="votes" data-shortcut="V">\r
votes</a>\r
</div>\r
</div>\r
</div>\r
</div>\r
\r
\r
\r
\r
\r
<a name="11162326"></a>\r
<div id="answer-11162326" class="answer" data-answerid="11162326" itemscope itemtype="http://schema.org/Answer">\r
<table>\r
<tr>\r
<td class="votecell">\r
\r
\r
<div class="vote">\r
<input type="hidden" name="_id_" value="11162326">\r
<a class="vote-up-off" title="This answer is useful">up vote</a>\r
<span itemprop="upvoteCount" class="vote-count-post ">20</span>\r
<a class="vote-down-off" title="This answer is not useful">down vote</a>\r
\r
\r
\r
\r
</div>\r
\r
</td>\r
\r
\r
\r
<td class="answercell">\r
<div class="post-text" itemprop="text">\r
<p>Here is working code</p>
<pre><code>import urllib2
url = \'http://www.abc.com/index.html\'
username = \'user\'
password = \'pass\'
p = urllib2.HTTPPasswordMgrWithDefaultRealm()
p.add_password(None, url, username, password)
handler = urllib2.HTTPBasicAuthHandler(p)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
page = urllib2.urlopen(url).read()
</code></pre>
</div>\r
<table class="fw">\r
<tr>\r
<td class="vt">\r
<div class="post-menu"><a href="/a/11162326" title="short permalink to this answer" class="short-link" id="link-post-11162326">share</a><span class="lsep">|</span><a href="/posts/11162326/edit" class="suggest-edit-post" title="">improve this answer</a></div> </td>\r
\r
\r
\r
<td align="right" class="post-signature"> \r
\r
\r
<div class="user-info ">\r
<div class="user-action-time">\r
answered <span title="2012-06-22 18:48:07Z" class="relativetime">Jun 22 \'12 at 18:48</span>\r
</div>\r
<div class="user-gravatar32">\r
<a href="/users/813102/big"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/5fc54ef1351c176ff60ac9a7c1ee6f8b?s=32&d=identicon&r=PG" alt="" width="32" height="32"></div></a>\r
</div>\r
<div class="user-details">\r
<a href="/users/813102/big">big</a>\r
<div class="-flair">\r
<span class="reputation-score" title="reputation score " dir="ltr">732</span><span title="4 gold badges"><span class="badge1"></span><span class="badgecount">4</span></span><span title="15 silver badges"><span class="badge2"></span><span class="badgecount">15</span></span><span title="34 bronze badges"><span class="badge3"></span><span class="badgecount">34</span></span>\r
</div>\r
</div>\r
</div>\r
</td>\r
</tr>\r
</table>\r
</td>\r
</tr>\r
\r
<tr>\r
<td class="votecell"></td>\r
<td>\r
\t <div id="comments-11162326" class="comments js-comments-container dno">\r
\t\t <table>\r
<tbody class="js-comments-list"\r
data-remaining-comments-count="0"\r
data-canpost="false"\r
data-cansee="true"\r
data-comments-unavailable="false"\r
data-addlink-disabled="true">\r
\r
<tr><td></td><td></td></tr>\r
</tbody>\r
\t\t </table>\r
\t </div>\r
\r
<div id="comments-link-11162326" data-rep=50 data-anon=true>\r
\r
<a class="js-add-link comments-link disabled-link "\r
title="Use comments to ask for more information or suggest improvements. Avoid comments like \xe2\x80\x9c+1\xe2\x80\x9d or \xe2\x80\x9cthanks\xe2\x80\x9d."\r
>add a comment</a><span class="js-link-separator dno"> | </span>\r
<a class="js-show-link comments-link dno" title="expand to show all comments on this post" href=# onclick=""></a>\r
</div> \r
</td>\r
</tr> </table>\r
</div>\r
<div id="dfp-mlb" class="everyonelovesstackoverflow"></div>\r
\r
<a name="24815585"></a>\r
<div id="answer-24815585" class="answer" data-answerid="24815585" itemscope itemtype="http://schema.org/Answer">\r
<table>\r
<tr>\r
<td class="votecell">\r
\r
\r
<div class="vote">\r
<input type="hidden" name="_id_" value="24815585">\r
<a class="vote-up-off" title="This answer is useful">up vote</a>\r
<span itemprop="upvoteCount" class="vote-count-post ">5</span>\r
<a class="vote-down-off" title="This answer is not useful">down vote</a>\r
\r
\r
\r
\r
</div>\r
\r
</td>\r
\r
\r
\r
<td class="answercell">\r
<div class="post-text" itemprop="text">\r
<p>I think you can use requests module which would make it be more easy for you.</p>
<pre><code>import requests
username = \'user\'
password = \'pass\'
url = \'http://www.example.com/index.html\'
r = requests.get(url, auth=(username, password))
page = r.content()
print page
</code></pre>
</div>\r
<table class="fw">\r
<tr>\r
<td class="vt">\r
<div class="post-menu"><a href="/a/24815585" title="short permalink to this answer" class="short-link" id="link-post-24815585">share</a><span class="lsep">|</span><a href="/posts/24815585/edit" class="suggest-edit-post" title="">improve this answer</a></div> </td>\r
\r
\r
\r
<td align="right" class="post-signature"> \r
\r
\r
<div class="user-info user-hover">\r
<div class="user-action-time">\r
answered <span title="2014-07-18 00:19:06Z" class="relativetime">Jul 18 \'14 at 0:19</span>\r
</div>\r
<div class="user-gravatar32">\r
<a href="/users/3552975/lerner"><div class="gravatar-wrapper-32"><img src="https://i.stack.imgur.com/UAdnO.png?s=32&g=1" alt="" width="32" height="32"></div></a>\r
</div>\r
<div class="user-details">\r
<a href="/users/3552975/lerner">lerner</a>\r
<div class="-flair">\r
<span class="reputation-score" title="reputation score " dir="ltr">1,155</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="11 silver badges"><span class="badge2"></span><span class="badgecount">11</span></span><span title="22 bronze badges"><span class="badge3"></span><span class="badgecount">22</span></span>\r
</div>\r
</div>\r
</div>\r
</td>\r
</tr>\r
</table>\r
</td>\r
</tr>\r
\r
<tr>\r
<td class="votecell"></td>\r
<td>\r
\t <div id="comments-24815585" class="comments js-comments-container ">\r
\t\t <table>\r
<tbody class="js-comments-list"\r
data-remaining-comments-count="0"\r
data-canpost="false"\r
data-cansee="true"\r
data-comments-unavailable="false"\r
data-addlink-disabled="true">\r
\r
\r
\r
<tr id="comment-44546076" class="comment js-comment ">\r
<td class="js-comment-actions comment-actions">\r
<table>\r
<tbody>\r
<tr>\r
<td class=" comment-score">\r
<span title="number of 'useful comment' votes received"\r
class="cool">1</span>\r
</td>\r
<td>\r
\r
</td>\r
</tr>\r
</tbody>\r
</table>\r
</td>\r
<td class="comment-text js-comment-text-and-form">\r
<div style="display: block;" class="comment-body">\r
<span class="comment-copy">Could be because of my python version, but just to let others know: I had to remove the parentheses on r.content() to get this to work (page = r.content).</span>\r
– <a href="/users/153336/erlend-d"\r
title="1,128 reputation"\r
class="comment-user">Erlend D.</a>\r
<span class="comment-date" dir="ltr"><span title="2015-01-22 08:25:30Z" class="relativetime-clean">Jan 22 \'15 at 8:25</span></span>\r
</div>\r
</td>\r
</tr>\r
</tbody>\r
\t\t </table>\r
\t </div>\r
\r
<div id="comments-link-24815585" data-rep=50 data-anon=true>\r
\r
<a class="js-add-link comments-link disabled-link "\r
title="Use comments to ask for more information or suggest improvements. Avoid comments like \xe2\x80\x9c+1\xe2\x80\x9d or \xe2\x80\x9cthanks\xe2\x80\x9d."\r
>add a comment</a><span class="js-link-separator dno"> | </span>\r
<a class="js-show-link comments-link dno" title="expand to show all comments on this post" href=# onclick=""></a>\r
</div> \r
</td>\r
</tr> </table>\r
</div>\r
<a name=\'new-answer\'></a>\r
<form id="post-form" action="/questions/10195915/answer/submit" method="post" class="post-form">\r
<input type="hidden" id="post-id" value="10195915" />\r
<input type="hidden" id="qualityBanWarningShown" name="qualityBanWarningShown" value="false" />\r
<input type="hidden" name="referrer" value=""/>\r
<h2 class="space">Your Answer</h2>\r
\r
\r
<script>\r
StackExchange.ifUsing("editor", function () {\r
StackExchange.using("externalEditor", function () {\r
StackExchange.using("snippets", function () {\r
StackExchange.snippets.init();\r
});\r
});\r
}, "code-snippets");\r
</script>\r
\r
\r
<script>\r
StackExchange.ready(function() {\r
initTagRenderer("".split(" "), "".split(" "));\r
\r
StackExchange.using("externalEditor", function() {\r
// Have to fire editor after snippets, if snippets enabled\r
if (StackExchange.settings.snippets.snippetsEnabled) {\r
StackExchange.using("snippets", function() {\r
createEditor();\r
});\r
}\r
else {\r
createEditor();\r
}\r
});\r
\r
function createEditor() {\r
StackExchange.prepareEditor({\r
heartbeatType: \'answer\',\r
convertImagesToLinks: true,\r
reputationToPostImages: 10,\r
bindNavPrevention: true,\r
postfix: "",\r
onDemand: true,\r
discardSelector: ".discard-answer"\r
,immediatelyShowMarkdownHelp:true\r
});\r
\r
\r
}\r
});\r
</script>\r
\r
\r
<div id="post-editor" class="post-editor js-post-editor">\r
\r
<div style="position: relative;"> \r
<div class="wmd-container">\r
<div id="wmd-button-bar" class="wmd-button-bar"></div>\r
<textarea id="wmd-input" class="wmd-input" name="post-text" cols="92" rows="15" tabindex="101" data-min-length=""></textarea>\r
</div>\r
</div>\r
\r
<div class="fl" style="margin-top: 8px; height:24px;"> </div>\r
<div id="draft-saved" class="draft-saved community-option fl" style="margin-top: 8px; height:24px; display:none;">draft saved</div>\r
\r
<div id="draft-discarded" class="draft-discarded community-option fl" style="margin-top: 8px; height:24px; display:none;">draft discarded</div>\r
\r
\r
\r
<div id="wmd-preview" class="wmd-preview"></div>\r
<div></div>\r
<div class="edit-block">\r
<input id="fkey" name="fkey" type="hidden" value="11a5d05d53ee3d8ae156544f3b2db468">\r
<input id="author" name="author" type="text">\r
</div>\r
\r
\r
\r
</div>\r
\r
<div style="position: relative;">\r
\r
<div class="form-item dno new-post-login">\r
\r
<div class="new-login-form">\r
<div class="new-login-left">\r
<h3>Sign up or <a id="login-link" href="/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f10195915%2fpython-urllib2-httperror-http-error-401-unauthorized%23new-answer">log in</a></h3>\r
<script>\r
StackExchange.ready(function () {\r
StackExchange.helpers.onClickDraftSave(\'#login-link\');\r
});\r
</script>\r
<div class="preferred-login google-login">\r
<svg aria-hidden="true" class="svg-icon native iconGoogle" width="18" height="18" viewBox="0 0 18 18"><g><path d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18z" fill="#4285F4"/><path d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17z" fill="#34A853"/><path d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18l2.67-2.07z" fill="#FBBC05"/><path d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.77 4.77 0 0 1 4.48-3.3z" fill="#EA4335"/></g></svg> Sign up using Google\r
</div>\r
<div class="preferred-login facebook-login">\r
<svg aria-hidden="true" class="svg-icon iconFacebook" width="18" height="18" viewBox="0 0 18 18"><path d="M1.88 1C1.4 1 1 1.4 1 1.88v14.24c0 .48.4.88.88.88h7.67v-6.2H7.46V8.4h2.09V6.61c0-2.07 1.26-3.2 3.1-3.2.88 0 1.64.07 1.87.1v2.16h-1.29c-1 0-1.19.48-1.19 1.18V8.4h2.39l-.31 2.42h-2.08V17h4.08c.48 0 .88-.4.88-.88V1.88c0-.48-.4-.88-.88-.88H1.88z" fill="#3C5A96"/></svg> Sign up using Facebook\r
</div>\r
<div class="preferred-login stackexchange-login">\r
<svg aria-hidden="true" class="svg-icon native iconLogoGlyphXSm" width="18" height="18" viewBox="0 0 18 18"><g><path fill="#BCBBBB" d="M14 16v-5h2v7H2v-7h2v5z"/><path d="M5 15v-2h8v2H5zM12.09.72l4.5 6.06-1.2.9-4.51-6.06 1.21-.9zM8.34 4.3l.97-1.16 5.8 4.83-.96 1.16-5.8-4.83zm-1.9 3.36l.64-1.37 6.85 3.19-.63 1.37-6.85-3.2zM5.4 11.39l.38-1.67 7.42 1.48-.22 1.46-7.58-1.27z" fill="#F48024"/></g></svg> Sign up using Email and Password\r
</div>\r
</div>\r
<input type="hidden" name="manual-openid" class="manual-openid" />\r
<input type="hidden" name="use-facebook" class="use-facebook" value="false" />\r
<input type="hidden" name="use-google" class="use-google" value="false" />\r
<input type="button" class="submit-openid" value="Submit" style="display:none" />\r
<div class="new-login-right">\r
<h3>Post as a guest</h3>\r
<div class="form-item">\r
<table>\r
<tr>\r
<td class="vm">\r
<div>\r
<label for="display-name">Name</label>\r
<input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105">\r
</div>\r
<div>\r
<label for="m-address">Email</label>\r
<input id="m-address" name="m-address" type="email" size="30" maxlength="100" value="" tabindex="106" placeholder="required, but never shown" />\r
</div>\r
</td>\r
</tr>\r
</table>\r
</div>\r
\r
</div>\r
</div>\r
</div>\r
<script>\r
StackExchange.ready(\r
function () {\r
StackExchange.openid.initPostLogin(\'.new-post-login\', \'https%3a%2f%2fstackoverflow.com%2fquestions%2f10195915%2fpython-urllib2-httperror-http-error-401-unauthorized%23new-answer\', \'question_page\');\r
}\r
);\r
</script>\r
<noscript>\r
<h3>Post as a guest</h3>\r
<div class="form-item">\r
<table>\r
<tr>\r
<td class="vm">\r
<div>\r
<label for="display-name">Name</label>\r
<input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105">\r
</div>\r
<div>\r
<label for="m-address">Email</label>\r
<input id="m-address" name="m-address" type="email" size="30" maxlength="100" value="" tabindex="106" placeholder="required, but never shown" />\r
</div>\r
</td>\r
</tr>\r
</table>\r
</div>\r
\r
</noscript>\r
\r
</div>\r
\r
<div class="form-submit cbt">\r
<input id="submit-button" type="submit" value="Post Your Answer" tabindex="110">\r
<a href="#" class="btn-clear discard-answer dno">discard</a>\r
\r
<p class="privacy-policy-agreement">\r
By posting your answer, you agree to the <a href=\'https://stackexchange.com/legal/privacy-policy\' name=\'privacy\' target=\'_blank\'>privacy policy</a> and <a href=\'https://stackexchange.com/legal/terms-of-service\' name=\'tos\' target=\'_blank\'>terms of service</a>.</p>\r
<input type="hidden" name="legalLinksShown" value="1" /> </div>\r
</form>\r
\r
\r
\r
<h2 class="bottom-notice" data-loc="1">\r
Not the answer you're looking for? Browse other questions tagged <a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/authentication" class="post-tag" title="show questions tagged 'authentication'" rel="tag">authentication</a> or <a href="/questions/ask">ask your own question</a>. </h2>\r
</div>\r
</div>\r
<div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar">\r
<div class="module question-stats">\r
<table id="qinfo">\r
<tr>\r
<td>\r
<p class="label-key">asked</p>\r
</td>\r
<td style="padding-left: 10px">\r
<p class="label-key" title="2012-04-17 17:18:28Z"><b>5 years, 8 months ago</b></p>\r
</td>\r
</tr>\r
<tr>\r
<td>\r
<p class="label-key">viewed</p>\r
</td>\r
\r
<td style="padding-left: 10px">\r
<p class="label-key">\r
<b>30,831 times</b>\r
</p>\r
</td>\r
</tr>\r
<tr>\r
<td>\r
<p class="label-key">active</p>\r
</td>\r
<td style="padding-left: 10px">\r
<p class="label-key"><b><a href="?lastactivity" class="lastactivity-link" title="2014-07-18 00:19:06Z">3 years, 5 months ago</a></b></p>\r
</td>\r
</tr>\r
</table>\r
</div>\r
\r
<div id="dfp-tsb" class="everyonelovesstackoverflow"></div>
<div id="hireme"></div>
<script>;window.clc=window.clc||{},window.clc.init=window.clc.init||function(a){var b=window,c=b.document;try{if("function"!=typeof[].indexOf||!window.addEventListener||!a.allowed)return;var d=new RegExp(a.allowed);if(!d.test(location.hostname))return;if(b.clc.options)for(var e in b.clc.options)a[e]=b.clc.options[e];b.clc.cmd="undefined"==typeof b.clc.cmd?[]:b.clc.cmd,b.clc.autoload=b.clc.autoload||function(){"function"==typeof b.clc.load?b.clc.load():b.clc.cmd.push(function(a){a.load()})};var f=a.wv;if(c.hidden&&f)return void c.addEventListener("visibilitychange",function b(){c.hidden||(window.clc.init(a),c.removeEventListener("visibilitychange",b))});b.clc.options=a,a.al&&b.clc.autoload();var g=/Trident/i.test(navigator.userAgent)?a.lib.replace(/(\\.min)?\\.js(\\?v=[0-9a-fA-F]+)?$/,".ie$1.js$2"):a.lib,h=c.createElement("script");h.async=!0,h.src=g,c.body.appendChild(h)}catch(a){}},window.clc.loadDisplayAds=window.clc.loadDisplayAds||function(){function a(b){b.style.height=b.style.maxHeight=b.style.minHeight="auto",b.style.display="IFRAME"===b.tagName?"none":"block",[].forEach.call(b.children,a)}function b(a){new Image().src="https://"+e+"/stalled.gif?"+a}var c=window,d=c.document,e="clc.stackoverflow.com",f={slots:{lb:[[728,90]],mlb:[[728,90]],sb:[[300,250],[300,600]],"tag-sponsorship":[[730,135]]},ids:{"dfp-tlb":"lb","dfp-mlb":"mlb","dfp-tsb":"sb","dfp-tag":"tag-sponsorship","clc-tlb":"lb","clc-mlb":"mlb","clc-tsb":"sb"}},g=/^\\/tags\\//.test(location.pathname)||/^\\/questions\\/tagged\\//.test(location.pathname)?"tag-pages":"question-pages",h=location.hostname;/^clc\\./.test(location.hostname)&&(h="test/dev.stackoverflow.com");var i=[4385506061,4386578282,4386579572];return function(e){var j=(e&&0<e.length?e:Object.keys(f.ids)).map(function(a){return d.getElementById(a)}).filter(function(a){return!!a&&/^\\s*$/.test(a.innerHTML)}).map(function(a){return a.id});if(0!==j.length){c.googletag=c.googletag||{},c.googletag.cmd=c.googletag.cmd||[],c.googletag.cmd.push(function(){var e=c.googletag,k=d.createElement("div");k.className="adsbox",k.id="clc-abd",k.style.position="absolute",k.style.pointerEvents="none",k.innerHTML=" ",d.body.appendChild(k);var l=e.pubads();l.enableSingleRequest(),l.addEventListener("slotRenderEnded",function(c){var e=c.serviceName,f=c.slot,g=c.lineItemId;try{var h=f.getSlotElementId(),j=[];h||j.push("id=0");var k=d.getElementById(h);if(!h||k?k.hasAttribute("data-clc-stalled")&&j.push("st=1"):j.push("el=0"),0!==j.length)return void b(j.join("&"));-1===i.indexOf(g)?k.setAttribute("data-clc-prefilled","true"):a(k),k.setAttribute("data-clc-ready","true")}catch(a){var l=d.getElementById("dfp-tsb")||d.getElementById("clc-tsb");l&&l.setAttribute("data-clc-ready","true"),b("e=1")}});var m=c.dfp_targeting||{};m&&Object.keys(m).forEach(function(a){l.setTargeting(a,m[a])});for(var n=0,o=j;n<o.length;n++){var p=o[n],q=f.ids[p],r=f.slots[q],s="/"+"248424177"+"/"+h+"/"+q+"/"+g,t=e.defineSlot(s,r,p);("tag-sponsorship"===q||"sb"==q)&&t.setCollapseEmptyDiv(!0,!0),t.addService(l),!1}e.enableServices();for(var p,u=0,v=j;u<v.length;u++)p=v[u],e.display(p)});var k=d.createElement("script");k.async=!0,k.src="https://www.googletagservices.com/tag/js/gpt.js",document.body.appendChild(k)}}}(),window.clc.init.call(null, {"lib":"https://cdn.sstatic.net/clc/clc.min.js?v=d6d5b5b197b2","style":"https://cdn.sstatic.net/clc/styles/clc.min.css?v=b18b3a2258df","u":"https://clc.stackoverflow.com/markup.js","wa":true,"kt":2000,"tto":true,"h":"clc.stackoverflow.com","allowed":"^(((talent\\\\.)?stackoverflow)|(blog\\\\.codinghorror)|(serverfault|askubuntu)|([^\\\\.]+\\\\.stackexchange))\\\\.com$","wv":true,"al":false,"ga":false});</script> <script>
window.clc_request=\'AhPnHXxiUtUIAAAAAMuTmwACAAAAAgAAAAAXAAAAfHB5dGhvbnxhdXRoZW50aWNhdGlvbnwAHB-s9R2oVqavnw\'; clc.autoload();
var dfp_targeting={Registered:[\'false\'],\'so-tag\':[\'python\',\'authentication\']}; clc.loadDisplayAds();
</script>\r
<div class="module sidebar-linked">\r
\t<h4 id="h-linked">Linked</h4>\r
\t<div class="linked" data-tracker="lq=1">\r
\r
<div class="spacer">\r
\t<a href="/q/27886502" title="Vote score (upvotes - downvotes)">\r
\t\t<div class="answer-votes default">0</div>\r
\t</a>\r
\t<a href="/questions/27886502/handling-http-authentication-via-python?noredirect=1" class="question-hyperlink">Handling HTTP Authentication via Python</a>\r
</div>\r
<div class="spacer">\r
\t<a href="/q/45469775" title="Vote score (upvotes - downvotes)">\r
\t\t<div class="answer-votes default">0</div>\r
\t</a>\r
\t<a href="/questions/45469775/authenticating-rest-api-with-python?noredirect=1" class="question-hyperlink">Authenticating REST API with Python</a>\r
</div>\t\t\t</div>\r
</div>\r
\r
<div class="module sidebar-related">\r
<h4 id="h-related">Related</h4>\r
<div class="related js-gps-related-questions" data-tracker="rq=1">\r
<div class="spacer"><a href="/q/1030113" title="Vote score (upvotes - downvotes)"><div class="answer-votes answered-accepted default">6</div></a><a href="/questions/1030113/does-urllib2-in-python-2-6-1-support-proxy-via-https" class="question-hyperlink">Does urllib2 in Python 2.6.1 support proxy via https</a></div><div class="spacer"><a href="/q/1152980" title="Vote score (upvotes - downvotes)"><div class="answer-votes answered-accepted default">3</div></a><a href="/questions/1152980/is-it-possible-to-fetch-a-https-page-via-an-authenticating-proxy-with-urllib2-in" class="question-hyperlink">Is it possible to fetch a https page via an authenticating proxy with urllib2 in Python 2.5?</a></div><div class="spacer"><a href="/q/5600955" title="Vote score (upvotes - downvotes)"><div class="answer-votes answered-accepted default">0</div></a><a href="/questions/5600955/open-url-using-personal-digital-ceritificate-with-urllib2" class="question-hyperlink">Open URL using personal digital ceritificate with urllib2</a></div><div class="spacer"><a href="/q/13128146" title="Vote score (upvotes - downvotes)"><div class="answer-votes default">0</div></a><a href="/questions/13128146/download-affy-annotation-file-with-python" class="question-hyperlink">Download affy annotation file with python</a></div><div class="spacer"><a href="/q/18534552" title="Vote score (upvotes - downvotes)"><div class="answer-votes answered-accepted default">4</div></a><a href="/questions/18534552/python-urllib2-basic-authentication" class="question-hyperlink">python urllib2 basic authentication</a></div><div class="spacer"><a href="/q/20873171" title="Vote score (upvotes - downvotes)"><div class="answer-votes default">0</div></a><a href="/questions/20873171/urllib2-httperror-http-error-400-bad-request" class="question-hyperlink">urllib2.HTTPError: HTTP Error 400: Bad Request</a></div><div class="spacer"><a href="/q/21061144" title="Vote score (upvotes - downvotes)"><div class="answer-votes default">0</div></a><a href="/questions/21061144/cant-make-post-request" class="question-hyperlink">Can't make POST request</a></div><div class="spacer"><a href="/q/21729255" title="Vote score (upvotes - downvotes)"><div class="answer-votes default">5</div></a><a href="/questions/21729255/urllib2-httperror-http-error-401-unauthorized" class="question-hyperlink">urllib2.HTTPError: HTTP Error 401: Unauthorized</a></div><div class="spacer"><a href="/q/27886502" title="Vote score (upvotes - downvotes)"><div class="answer-votes default">0</div></a><a href="/questions/27886502/handling-http-authentication-via-python" class="question-hyperlink">Handling HTTP Authentication via Python</a></div><div class="spacer"><a href="/q/36944306" title="Vote score (upvotes - downvotes)"><div class="answer-votes default">0</div></a><a href="/questions/36944306/python-urllib2-httperror-http-error-405-method-not-allowed" class="question-hyperlink">python: urllib2.HTTPError: HTTP Error 405: Method Not Allowed</a></div>\r
</div>\r
</div>\r
\r
<div id="hot-network-questions" class="module tex2jax_ignore">\r
<h4>\r
<a href="https://stackexchange.com/questions?tab=hot"\r
class="js-gps-track" \r
data-gps-track="posts_hot_network.click({ item_type:1, location:11 })">\r