python+selenium:抓取网页新闻列表元素,并记录标题和链接地址,保存到excel文档中
#!/usr/local/bin/python3
# !python3.9
# -*- coding: UTF-8 -*-
'''
@File:xwzx1.py
@Time:2021-09-09 18:32
@Author:user
抓取网页新闻列表元素,并记录标题和链接地址,保存到excel文档中
'''
from selenium import webdriver
from os.path import join
import os
import sys
from time import strftime
from time import sleep
import xlrd
import xlwt
excel_dir=os.path.dirname(os.path.abspath(__file__))
now_time=strftime("%Y-%m-%d-%H-%M")
class text_xwzx():
def __init__(self):
self.url="http://www.sinopecgroup.com/group/xwzx/"
self.filename=now_time+".xls"
self.path