01 爬取IEEE会议的论文题目,使用关键词分类过滤

这里以IEEE里面的PIMRC17‘,WCNC17’,GLOBECOM17‘为例,需要用到的库:
bs4里面的BeautifulSoup,requests。

step1

downtitle.py
这个文件里,我们要写一下如何获取题目。

def get_title(conference, url, total_page):
    from bs4 import BeautifulSoup
    import requests
    import time
    if conference == 'wcnc':
        f2 = open("wcnc2017.txt", "a")
    elif conference == 'pimrc':
            f2 = open("pimrc2017.txt", "a")
    elif conference == 'globecom':
            f2 = open("globecom2017.txt", "a")
    for i in range(1, total_page+1):  # 假设最多有total_page页,你也可以自动化
        #time.sleep(5)
        url_this = url + str(i)
        wb_data = requests.get(url_this)
        soup = BeautifulSoup(wb_data.text, 'lxml')
        titles = soup.select('#results-blk > div > ul > li > div.txt > h3 > a > span')  # 解析题目列表
        print(titles)
        for title in titles:
            temp = str(title.get_text())
            print(temp)
            if len(temp)>20:
                f2.write(temp+'\n')
        print(conference+' page: '+str(i))
    return f2

STEP2

主文件,用来把会议的题目写进txt里面,这里面的三个网址我都是在对应会议的页面加上钩子条件得到的,页码去掉了。每页显示100条。

import downtitle

PIMRC17 = 'https://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=8288420&punumber%3D8288420%26filter%3DAND%28p_IS_Number%3A8292162%29%26rowsPerPage%3D100&rowsPerPage=100&pageNumber='
GLOBE17 = 'https://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=8253768&punumber%3D8253768%26filter%3DAND%28p_IS_Number%3A8253909%29%26rowsPerPage%3D100&rowsPerPage=100&pageNumber='
WCNC17 = 'https://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=7924448&punumber%3D7924448%26filter%3DAND%28p_IS_Number%3A7925429%29%26pageNumber%3D4%26rowsPerPage%3D100&pageNumber='
WCNC17txt = downtitle.get_title('wcnc', WCNC17,5)
PIMRC17txt = downtitle.get_title('pimrc',PIMRC17,7)
GLOBE17txt = downtitle.get_title('globecom',GLOBE17, 11)

STEP3

统计不同话题的题目,注意在匹配的时候有的时候大小写是不好搞定的,因此匹配字符串的时候,就应该是取单词主题部分,有时候可以去掉首字母,再匹配:

topics = (1,11)#10 topics
filewcnc = open("wcnc2017.txt", "r")
filepimrc = open("pimrc2017.txt", "r")
fileglobecom = open("globecom2017.txt", "r")

count_D2D = 0
count_self_organization = 0
count_vehicle = 0
count_cooperation = 0
count_incentive = 0
count_interference = 0
count_bigdata = 0
count_crowdsourcing = 0
count_privacy = 0
count_IoT = 0

for i in range(1,4):
    if i == 1:
        filetoscrapy = filewcnc
        conference_name = 'WCNC_2017'
    elif i == 2:
        filetoscrapy = filepimrc
        conference_name = 'PIMRC_2017'
    elif i ==3:
        filetoscrapy = fileglobecom
        conference_name = 'GLOBECOM_2017'

    for temp in filetoscrapy:

        index_of_D2D = open("D2d中继.txt", "a")         #D2D
        justify_D2D = (('D2D' in temp) or ('elay' in temp) or (temp.count('evice')>=2))
        if justify_D2D:
            index_of_D2D.write(conference_name+', '+ temp)
            count_D2D += 1

        index_of_self_organization = open("自组织和传感器.txt", "a")  #自组织和传感器
        justify_self_organization = (('d-hoc' in temp) or ('ensor' in temp) or(('elf' in temp) and ('rganiz' in temp)))
        if justify_self_organization:
            index_of_self_organization.write(conference_name+', '+ temp)
            count_self_organization += 1

        index_of_vehicle = open("车联网.txt", "a")    #车联网
        justify_vehicle = (('ehicular' in temp) or ('ehicle' in temp))
        if justify_vehicle:
            index_of_vehicle.write(conference_name+', '+ temp)
            count_vehicle += 1

        index_of_cooperation = open("协作通信.txt", "a")  #协作通信
        justify_cooperation = (('ollab' in temp) or ('ooperat' in temp) or ('oordinat' in temp))
        if justify_cooperation:
            index_of_cooperation.write(conference_name+', '+ temp)
            count_cooperation += 1

        index_of_incentive = open("合作激励.txt", "a")
        justify_incentive =('ncentive' in temp)
        if justify_incentive:
            index_of_incentive.write(conference_name+', '+ temp)
            count_incentive += 1

        index_of_interference= open("干扰协调管理缓解.txt", "a")
        justify_interference = ('nterference' in temp) and (('itigat' in temp) or ('anage' in temp) or ('ancell'in temp))
        if  justify_interference:
            index_of_interference.write(conference_name+', '+ temp)
            count_interference += 1

        index_of_bigdata = open("大数据.txt", "a")
        justify_bigdata = ((('Big' in temp) and ('Data' in temp)) or ('ig Data' in temp) or ('ig data' in temp))
        if justify_bigdata:
            index_of_bigdata.write(conference_name+', '+ temp)
            count_bigdata += 1

        index_of_crowdsourcing = open("众包.txt", "a")
        justify_crowdsourcing = ('rowdsourcing' in temp)
        if justify_crowdsourcing:
            index_of_crowdsourcing.write(conference_name+', '+ temp)
            count_crowdsourcing += 1

        index_of_privacy = open("安全隐私.txt", "a")
        justify_privacy = (('rivacy' in temp) or ('ecurity' in temp) or ('afty' in temp) or ('safe' in temp) or ('Safe' in temp))
        if justify_privacy:
            index_of_privacy.write(conference_name+', '+ temp)
            count_privacy += 1

        index_of_IoT = open("物联网.txt", "a")
        justify_IoT = (('IoT' in temp) or (('hings' in temp) and ('nternet' in temp)))
        if justify_IoT:
            index_of_IoT.write(conference_name+', '+ temp)
            count_IoT += 1

IEEE对于用户下载文件的权限要求很诡异,我用电脑下载时候,下下来的pdf都是损坏的,就算是用了带cookie的headers也是损坏,等我以后再研究吧。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,386评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,142评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,704评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,702评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,716评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,573评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,314评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,230评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,680评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,873评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,991评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,706评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,329评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,910评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,038评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,158评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,941评论 2 355

推荐阅读更多精彩内容

  • 今天看完了《说医不二》这本书。作者用通俗易懂的话讲述了中医的道理。 中医的起源来源于厨房,最早的《汤液经法》是中医...
    冰火两重天1116阅读 565评论 0 0