import urllib.request as ur import user_agent import lxml.etree as le request = ur.Request( url='https://edu.csdn.net/mycollege', headers={ 'User-Agent':user_agent.get_user_agent_pc(), 'Cookie':'*******', } ) response = ur.urlopen(request).read().decode('utf-8') # with open('mycollege2.html','w',encoding='utf-8') as f: # f.write(response) html_x = le.HTML(response) title_s = html_x.xpath('//li[@class="item_box"]//h1/a/text()') print(title_s)