我编写了一个CGI脚本,用于从表单中获取一些数据,然后使用selenium(python)使用该数据登录,但我总是得到“:消息:无法加载配置文件 . 配置文件目录:%s如果您指定FirefoxBinary构造函数中的log_file,检查它是否有详细信息 . “
该文件保存为website.py
这是我的代码......
#!/usr/bin/python
print "Content-type: text/html"
from urllib2 import urlopen
from selenium import webdriver
import time
import sys
import MySQLdb
from BeautifulSoup import *
from pyvirtualdisplay import Display
import cgi
import cgitb
cgitb.enable()
print """<html>
<head>
</head>
<body>
<div class="left-column">
</div>
<div class="right-column">
<h1 class="main-heading">Post your Comments on sample.com: Step 1</h1>
"""
form = cgi.FieldStorage()
if form.getvalue("fullname"):
name=form.getvalue("fullname")
email = form.getvalue("email")
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Firefox()
driver.get("https://sample.com")
# phone = form.getvalue("phone")
print """ <form action="website.py" method="post">
<i>Your Name:</i>
<input type="text" name="fullname" class="textbox">
<i>Your Email:</i>
<input type="text" name="email" class="textbox">
<i>Your Phone Number: (optional)</i>
<input type="text" name="phone" class="textbox">
<input class="btn" type="submit" value="Next" style="width: 150px; height: 40px; font-size: 14px;">
</form>
</div>
</body>
</html> """
1 回答
我怀疑问题是你的python CGI脚本是作为服务器运行的,而不是你,你所看到的是某种权限问题 . . .