我正在开发一个项目,该项目将登录该站点并评论用户生成的内容。
我使用 selenium、chrome 驱动程序和 python 3。所有凭据用户名、密码和 chromedriver 位置都在单独的 config.ini 文件中配置。
这是python脚本:
#!/usr/bin/python
import os
import time
import getpass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from configparser import ConfigParser
# Reading configuration file
config = configparser.ConfigParser()
config.sections()
parser = ConfigParser()
parser.read('config.ini')
parameters = {}
for pairs in parser.sections(): # Parse the configuration file
for name, value in parser.items(pairs):
parameters[name] = value
# Automating your browser
chromedriver = parameters["path"]
os.environ["webdriver.chrome.driver"] = chromedriver
#Uncomment this block if you don't want images …Run Code Online (Sandbox Code Playgroud)