直接下载到本地搞
# -*- coding=utf-8 -*-
import re
import requests
import time
from bs4 import BeautifulSoup
class Acauto(object):
def __init__(self):
object.__init__(self)
self.session = requests.Session()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'
}
self.session.headers.update(headers)
def get(self):
soup = BeautifulSoup(''.join(open('jiaoyi.html', 'r', encoding='utf-8').read()), 'lxml')
soup = soup.find('table',attrs={'class':'table search_'})
soup = soup.find_all('td')
for line in soup:
print(line.text)
if __name__ == '__main__':
c = Acauto()
c.get()