def get_trending(cls): r = get_text(cls.GITHUB_REDIAN, options=cls.GITHUB_HEADERS) soup = etree.HTML(r.text) for soup_a in soup.xpath("//article[@class='Box-row']"): gh_title = soup_a.xpath('string(./h1/a)').strip() gh_url = "https://github.com/" + soup_a.xpath('./h1/a/@href')[0] print(f"Name: {gh_title}, URL: {gh_url}")
def get_trending(cls): r = get_text(cls.V2EX_REDIAN) soup = etree.HTML(r.text) for soup_a in soup.xpath("//span[@class='item_title']/a"): vsite_name = soup_a.text vsite_url = cls.V2EX_URL + soup_a.get('href') print(f"Name: {vsite_name}, URL: {vsite_url}")
def get_trending(cls): r = get_text(cls.ZHIHU_REDIAN, cls.HEADERS) r.encoding = "utf-8" soup = etree.HTML(r.text) for soup_a in soup.xpath("//div[@class='HotItem-content']/a"): zhihu_title = soup_a.get('title') zhihu_url = soup_a.get('href') print(f"Name: {zhihu_title}, URL: {zhihu_url}")
def get_trending(cls): r = get_text(cls.BAIDU_REDIAN) r.encoding = 'gb2312' soup = etree.HTML(r.text) for soup_a in soup.xpath("//a[@class='list-title']"): bd_title = soup_a.text bd_url = soup_a.get('href') print(f"Name: {bd_title}, URL: {bd_url}")
def get_trending(cls): r = get_text(cls.WEIBO_REDIAN) r.encoding = 'utf-8' soup = etree.HTML(r.text) for soup_a in soup.xpath("//td[@class='td-02']/a"): wb_title = soup_a.text wb_url = cls.WEIBO_URL + soup_a.get('href') if "javascript:void(0)" in wb_url: continue print(f"Name: {wb_title}, URL: {wb_url}")