Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python 3.3.3从受密码保护的网页检索数据_Python_Passwords_Urllib_Python 3.3 - Fatal编程技术网

使用Python 3.3.3从受密码保护的网页检索数据

使用Python 3.3.3从受密码保护的网页检索数据,python,passwords,urllib,python-3.3,Python,Passwords,Urllib,Python 3.3,我试图使用urllib访问一个网站,然后剥离页面源代码,以便从中收集一些数据。我知道如何对公共网站执行此操作,但我不知道如何使用urllib对受密码保护的网页执行此操作。我知道用户名和密码,我只是对如何让urllib放入正确的凭据,然后将我重新路由到要从中删除数据的正确页面感到非常困惑。目前,我的代码如下所示。问题是它正在调出登录页面的源代码 from tkinter import * import csv from re import findall import urllib.request

我试图使用urllib访问一个网站,然后剥离页面源代码,以便从中收集一些数据。我知道如何对公共网站执行此操作,但我不知道如何使用urllib对受密码保护的网页执行此操作。我知道用户名和密码,我只是对如何让urllib放入正确的凭据,然后将我重新路由到要从中删除数据的正确页面感到非常困惑。目前,我的代码如下所示。问题是它正在调出登录页面的源代码

from tkinter import *
import csv
from re import findall
import urllib.request
    def info():    

        file = filedialog.askopenfilename()
        fileR = open(file, 'r')
        hold = csv.reader(fileR, delimiter=',', quotechar='|')
        aList=[]
        for item in hold:
            if item[1] and item[2] == "":
                print(item[1])
                url = "www.example.com/id=" + item[1]
                request = urllib.request.urlopen(url)
                html = request.read()
                data = str(html)
                person = findall('''\$MainContent\$txtRecipient\"\stype=\"text\"\svalue=\"([^\"]+)\"''',data)
            else:
                pass

        fileR.close

记住,我使用的是python 3.3.3。任何帮助都将不胜感激

这可能会对您有所帮助:我知道您已经问过如何使用urllib来实现这一点,但使用python请求库可能值得一试。非常有助于拉网