为何爬取不了淘宝的数据?

 import requests
import re
def getHTMLtext(url):
    try:
        r = requests.get(url, timeout = 30)
        r.raise_for_status()
        r.encoding = r.apparent_encoding
        return r.text
    except:
        return ' '
def parsePage(clist, html):
    try:
        plt = re.findall(r'\'view_price\'\:\'[\d\.]*\' ' ,html)
        tlt = re.findall(r'\'raw_title\'\:\'.*?\' ' ,html)
        for i in range(len(plt)):
            price = eval(plt[i].split(':')[1])
            title = eval(tlt[i].split(':')[1])
            clist.append([price, title])
    except:
        print('')
    print(clist)
def printGoodslist(clist):
    tplt = '{:4}\t{:10}\t{:16}'
    print(tplt.format('序号','价格','商品名称'))
    count = 0
    for c in clist:
        count += 1
        print(tplt.format(count, c[0], c[1]))


def main():
    goods = '书包'
    depth = 2
    start_url = 'https://s.taobao.com/search?q=' + goods
    infolist = []
    for i in range(depth):
        try:
            url = start_url + '&s=' + str(44*i)
            html = getHTMLtext(url)
            parsePage(infolist, html)
        except:
            continue
    printGoodslist(infolist)
main()


打印出来其中的clist列表是空的,是不是正则表达式写错了?

这是之前北京理工大学的一个关于python爬虫入门的国家精品课里面的程序。代码本身没问题,但是现在淘宝网要登陆,所以并不是获取的商品的信息。
print(html[2000:3000])可知“...为确保您账户的安全及正常使用,依《网络安全法》相关要求,6月1日起会员账户需绑定手机。如您还未绑定,请尽快完成,感谢您的理解及支持!...”跳出的是登陆页面。可以用京东的商品练习。

def parsePage(clist, html):
加上
print(htnl)
如果输出的html正常,并且有你要抓取的内容,就是正则表达式写错了,如果没有,就是抓取都没抓对

没有抓对的话,自己用抓包工具对比下,你的程序和浏览器的差别。