1 Star 1 Fork 1

Draycen/Spider

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
FD_Talk.py 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
Mingfei Gao 提交于 2017-05-11 15:49 . 增加特殊关键词过滤
# -*- coding: utf-8 -*-
######################
# Author : 高明飞
# Data : 2016-07-24
# Brief : 用于获取复旦公司招聘宣讲会的爬虫
######################
import WebsiteBase
import requests, time, re, logging, sqlite3
from bs4 import BeautifulSoup
class FD_Talk(WebsiteBase.WebsiteBase):
def __init__(self, Name, DBName, AgentID, KeyWords, SpecialKeyWords = []):
super().__init__(Name, DBName, AgentID, True, KeyWords, 3, SpecialKeyWords)
# Return number of pages
def GetPageRange(self):
return range(1)
# Use requests to get the main page, return response
def GetMainPage(self, page):
payload = {'count': 100}
return requests.get('http://www.career.fudan.edu.cn/jsp/career_talk_list.jsp', params=payload, timeout=21)
# Return soup
def GetEnclose(self, soup):
return soup.find('div', id='tab1')
# Return list of tag
def GetTags(self, soup):
return soup.find_all('div', id='tab1_bottom')
# Return title string
def GetTitle(self, tag):
return tag.find_all('div')[0].string
# Return URL string
def GetURL(self, tag):
basecontentURL = 'http://www.career.fudan.edu.cn/jsp/career_talk_detail.jsp?key='
contentsuffix = tag['key']
contentURL = basecontentURL + contentsuffix
return contentURL
# Return publish time
def GetPublishTime(self, tag):
return ''
# Addditon check, return True if unused
def AdditionCheck(self, tag):
if (tag.find_all('div')[0].string.count('已举办') > 0):
return False
else:
return True
# Return brief string
def GetBrief(self, tag, keywordstring):
# Get time & Location
talktime = tag.find_all('div')[2].string + ' ' + tag.find_all('div')[3].string
talkloc = tag.find_all('div')[4].string
# Generate BriefList
BriefString = talktime + '\r\n' + talkloc + '\r\n\r\n' + keywordstring
return BriefString
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Draycen/Spider.git
git@gitee.com:Draycen/Spider.git
Draycen
Spider
Spider
master

搜索帮助