#!/usr/bin/env python
#coding=utf-8

# @file fetch_all.py
# @brief 读取excel文件，查找引用这些文献的其他文献
# @author x565178035,x565178035@126.com
# @version 1.0
# @date 2017-12-11 09:12

import sys

reload(sys)
sys.setdefaultencoding("utf-8")

import xlrd
import re
import crawler
import random

google_urls = ["https://xue.glgoo.net",
               "https://sci-hub.org.cn",
               "https://g.nuist.top",
               ]
def fetch_all():
    data=xlrd.open_workbook("./source.xlsx")
    table=data.sheet_by_index(1)
    row,col=table.nrows,table.ncols
    for each in table.col_values(1):
        pattern = re.compile(ur'(“|").*(” |")')
        res=pattern.search(each)
        if res:
            paper_name=res.group()[1:-1].replace(",","").replace("”","")
            #  print paper_name.encode('utf8')
            crawler.google_url=random.choice(google_urls)
            crawler.paper_based_crawler(paper_name)


if __name__ == '__main__':
    fetch_all()

