Beispiel #1
0
 def get_event_info(self,event_url):
     if event_url:
         time.sleep(random.randint(0,3))
         response = requests.get(event_url,headers=random_header())
         status_code = response.status_code
         if status_code == 200:
             event_html = response.text
             eventsoup = BeautifulSoup(event_html,"html5lib")
             eventid = 0
             try:
                 eventid = int(event_url[event_url[:-1].rfind("/")+1:-1])
             except:
                 print(event_url)
             try:
                 activity = Activity(eventsoup, eventid)
             except Exception as e:
                 f = open('error_url.txt', 'a')
                 f.write(event_url + "\r\n")
                 f.close()
             dbhelper = DBHelper()
             dbhelper.store_data(activity)
             print(event_url,"数据插入完毕")
         else:
             f = open('error_url.txt','a')
             f.write(event_url+"\r\n")
             f.close()