柯摩的BLOG

Forget before get.


  • 首页

  • 人生小记

  • 关于

  • 标签118

  • 分类10

  • 归档32

  • 运动日记

  • 相册

  • 热门

  • 友链

  • 搜索

利用Selenium秒填朋友圈各种问卷星调查问卷

发表于 2020-05-13 分类于 Crawler 阅读次数: 阅读次数: | 字数: 581 评论数:
本文字数: 896 阅读时长 ≈ 1 分钟

这时代没人愿意填调查问卷,纯属无聊。

0️⃣ 前言

毕业季到了,要开始写论文了,朋友圈各种同学的各种课题的调查问卷,但几乎没什么人填,想帮他们随机填一填。

1️⃣ 实现功能

  • 目前还不算完善,只能填电脑端,手机端需要重新写逻辑,也就是链接里面要改成jq而不是m;
  • 默认自动填10份,可以在主函数的times里面修改数值;
  • 问卷链接在FillTheQuestionaire函数里面修改;
  • 写了代理更换,但没钱换代理,换了代理可以更加真实一点,不然老是一个地区的人填不好。

    2️⃣ 代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from selenium import webdriver
import time
import re
import os
from bs4 import BeautifulSoup
from lxml import etree
import random
import pandas as pd

def ChangeIP():
page = random.randint(1,4055)
url = 'https://www.xicidaili.com/nn/'
# url = 'https://www.kuaidaili.com/free/'
driverIP = webdriver.Chrome()
driverIP.get(url)
content = driverIP.page_source.encode('utf-8')
html = etree.HTML(content)
t = html.xpath("//div[@class='bar']/div[@class='bar_inner fast']")
flow = ['99%','98%']
for i in t:
if i.attrib['style'].split(":")[1] in flow:
index = t.index(i)
break
driverIP.quit()
data = pd.read_html(content)
ipinfo = data[0].values[index]
# ipinfo = random.choice(data[0].values)
ip = str(ipinfo[5]).lower() + "://" + str(ipinfo[1]) + ":" + str(ipinfo[2])
# ip = str(ipinfo[3]).lower() + "://" + str(ipinfo[0]) + ":" + str(ipinfo[1])
return ip

def FillTheQuestionaire(times):
url = 'https://www.wjx.cn/jq/74385885.aspx'
for t in range(times):
mobileEmulation = {'deviceName': 'iPhone X'}
options = webdriver.ChromeOptions()
options.add_experimental_option('mobileEmulation', mobileEmulation)
# options = webdriver.ChromeOptions()
# ip = ChangeIP()
# print(ip)
# options.add_argument("--proxy-server=" + ip)
# driver = webdriver.Chrome(chrome_options=options)
# if t % 2 == 0:
driver = webdriver.Chrome()
# else:
# driver = webdriver.Chrome(chrome_options=options)
driver.get(url)
content = driver.page_source.encode('utf-8')
html = etree.HTML(content)
soup = BeautifulSoup(content, 'lxml')
NumOfQuestions = len(driver.find_elements_by_xpath(
"//div[@class='div_question']"))
for quiz in range(NumOfQuestions):
try:
question = driver.find_elements_by_xpath("//div[@id='divquestion" + str(
quiz + 1) + "']//ul[@class='ulradiocheck']//li//a[@class='jqRadio']")
random.choice(question).click()
except:
pass
try:
tr = driver.find_elements_by_xpath(
"//div[@id='divquestion" + str(quiz + 1) + "']/table/tbody/tr")
for t in range(len(tr)):
button = driver.find_elements_by_xpath("//div[@id='divquestion" + str(
quiz + 1) + "']/table/tbody/tr[" + str(t + 1) + "]/td/a[@class='jqRadio']")
try:
random.choice(button).click()
except:
pass
except:
pass

try:
checkbox = driver.find_elements_by_xpath("//div[@id='divquestion" + str(
quiz + 1) + "']//ul[@class='ulradiocheck']//li//a[@class='jqCheckbox']")
YorN = [x for x in range(2)]
checkbox[0].click()
for i in range(len(checkbox) - 2):
if random.choice(YorN) == 1:
print("是")
try:
checkbox[i+1].click()
except:
pass
except:
pass
time.sleep(3)
driver.find_elements_by_xpath("//input[@id='submit_button']")[0].click()
time.sleep(2)
driver.quit()


if __name__ == "__main__":
times = 10
FillTheQuestionaire(times)
相关文章推荐
  • 一文解决--matplotlib绘制极坐标热力图并插值优化
  • 从零实现朴素贝叶斯分类器(离散情况)--以学生分班为例
  • 简单地打造一个搜索工具--爬取所有网页并创造单词的反向索引
  • 天池二手车价格预测Task1-2—赛题理解与数据分析
  • 高性能分布式计算(HPC)作业1--节点实时通信
喜欢就支持一下吧~
柯摩 微信支付

微信支付

柯摩 支付宝

支付宝

  • 本文作者: 柯摩
  • 本文链接: https://kemo.xyz/利用Selenium秒填朋友圈各种问卷星调查问卷.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
python pandas Selenium 朋友圈 问卷星 调查问卷
Tweet
Share
Link
Plus
Share
Class
Send
Send
Pin
从零实现朴素贝叶斯分类器(离散情况)--以学生分班为例
一文解决--matplotlib绘制极坐标热力图并插值优化
------------- 本 文 结 束 感 谢 您 的 阅 读 -------------
  • 文章目录
  • 站点概览
柯摩

柯摩

真实自有万钧之力
32 日志
10 分类
118 标签
RSS
GitHub E-Mail Weibo QQ Wechat Twitter Bilibili
Creative Commons
  1. 1. 0️⃣ 前言
  2. 2. 1️⃣ 实现功能
  3. 3. 2️⃣ 代码
0%

Tag Cloud

  • Algorithm1
  • Anaconda31
  • Barrier1
  • BeautifulSoup1
  • BoxPlot1
  • CUDA1
  • CVM1
  • DataMining3
  • Diary5
  • ECS1
  • ESXi3
  • Editor8
  • Go1
  • Hexo1
  • IPFS2
  • IQR1
  • Job1
  • Jupyter3
  • Jupyter Notebook1
  • Lasso正则化1
  • Learning1
  • LightGBM1
  • Linear Regression1
  • Linux8
  • MATLAB1
  • MySQL1
  • Navie Bayes1
  • Next1
  • Nvidia5
  • OJ1
  • Onehot1
  • PaddleOCR1
  • Pandas Head1
  • PySimpleGUI1
  • Pycharm1
  • Python1
  • Pytorch1
  • RTX 2070 Super4
  • Reading1
  • Ridge正则化1
  • SSH1
  • Science Uranology1
  • Searcher1
  • Selenium1
  • Sticker1
  • Study3
  • Thinking2
  • Tianchi3
  • Ubuntu8
  • VMware1
  • X Server1
  • XGBoost1
  • Xftp1
  • Xshell3
  • alive_progress1
  • cross validation1
  • css1
  • cuDNN1
  • custom1
  • distributed system3
  • fan1
  • groupby1
  • matplotlib1
  • multithreading3
  • nvidia-settings1
  • pandas7
  • python9
  • requests1
  • seaborn3
  • set_gpu_fans_public2
  • socket3
  • svm1
  • xorg.conf1
  • 二进制1
  • 五折交叉验证1
  • 内存优化1
  • 决策树1
  • 分布式1
  • 分布式计算2
  • 包裹式(wrapper)1
  • 博客1
  • 反向索引1
  • 回忆1
  • 地铁线路优化1
  • 多层感知机(MLP)1
  • 多线程3
  • 嵌入式(embedding)1
  • 感情1
  • 插值1
  • 数学建模1
  • 日记1
  • 朋友圈1
  • 朴素贝叶斯1
  • 极坐标1
  • 梯度提升树(GBDT)1
  • 正则表达式1
  • 正态分布1
  • 毕业论文1
  • 气象图1
  • 温馨1
  • 热力图1
  • 画图1
  • 目标函数1
  • 真挚1
  • 私有网络1
  • 约束条件1
  • 网格调参1
  • 节点通信3
  • 虚拟机3
  • 调查问卷1
  • 贝叶斯调参1
  • 贪心调参1
  • 过滤式(filter)1
  • 遗传算法1
  • 问卷星1
  • 随机森林1
  • 随笔2
  • 风扇1
© 2015 – 2021 柯摩 | 站点总字数: 162k | 站点阅读时长 ≈ 2:27
全站共 77.3k 字
载入天数...载入时分秒...
皖ICP备 - 19020907 | 苏公网安备 32050802011200号
总访客量 人 | 总访客数 次