代码:
# -*- coding=utf-8 -*-
import os
import threading
import time
import unittest
import xlwt
import xlrd
from xlutils.copy import copy
from selenium import webdriver
from queue import Queue
import warnings
warnings.simplefilter("ignore", ResourceWarning)
'''
腾讯职位的前 10 位数据, 并写入 excel, 每页有 10 条信息
https://careers.tencent.com/search.html?query=co_1&sc=1
(https://careers.tencent.com/search.html?query=co_1&index=1&sc=1)
https://careers.tencent.com/search.html?query=co_1&index=2&sc=1
https://careers.tencent.com/search.html?query=co_1&index=3&sc=1 # 第一页的 URL
'''
line_begin_nmb = 1 # 从第二行开始
dir = os.path.abspath('.').split('src')[0]
old_workbook = xlrd.open_workbook(dir + "./13腾讯求职信息模板.xls", formatting_info=True) # 把里面的格式复制过来
new_workbook = copy(old_workbook)
new_worksheet = new_workbook.get_sheet(0)
def style_font_xingkai(style): # 华文行楷
font = xlwt.Font()
font.name = u'华文行楷'
style.font = font
return style
def style_align_center(style): # 居中对齐
alignment = xlwt.Alignment()
alignment.horz = xlwt.Alignment.HORZ_CENTER
style.alignment = alignment
return style
def style_align_left(style): # 左对齐
alignment = xlwt.Alignment()
alignment.horz = xlwt.Alignment.HORZ_LEFT
alignment.wrap = 1
style.alignment = alignment
return style
def