fb_gsearch.py 616 B

123456789101112131415161718192021
  1. import gsearch_general
  2. import sys
  3. import dataset
  4. import datetime
  5. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  6. table=db['fb_gsearch']
  7. driver=gsearch_general.restart_browser()
  8. idx=gsearch_general.process_query(driver,'site:facebook.com pages 道路救援',number_results=100,language_code='zh-TW')
  9. print(idx)
  10. for x in idx:
  11. x['dt']=datetime.datetime.now()
  12. table.insert(x)
  13. if idx==None:
  14. print(driver.page_source)
  15. if '我們的系統偵測到您的電腦網路送出的流量有異常情況' in driver.page_source:
  16. print('baned.....')
  17. sys.exit()