Hello I am trying to run a python script on a Apache2 server based on Ubuntu. Here is the configuration of the server from the file 000-default.conf:
<Directory /usr/lib/cgi-bin/>
Options Indexes FollowSymLinks ExecCGI
AddHandler cgi-script .cgi .py
AllowOverride None
Require all granted
</Directory>
test.cgi is the name of the python script. It is located in /usr/lib/cgi-bin/
First I run this script and it runs perfectly:
#!/usr/bin/env python3
from math import sqrt
print("Content-type: text/html\n\n")
print("Hello World!\n")
a = sqrt(4)
print(a)
I import math library and it is ok.
Then I tried to add webdriver to navigate through url
#!/usr/bin/env python3
#from selenium import webdriver
print("Content-type: text/html\n\n")
print("Hello World!\n")
driver = webdriver.Firefox()
url = 'https://www.coteur.com/cotes-foot.php'
driver.get(url)
url_links = []
for i in driver.find_elements_by_xpath('//a[contains(@href, "match/cotes-")]'):
url_links.append(i.get_attribute('href'))
print(len(url_links), '\n')
print(url_links[0], '\n')
The goal is to go to https://www.coteur.com/cotes-foot.php and print the first url of soccer games list.
But the output is bad :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
webmaster@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.4.29 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>
I guess that the problem comes from webdriver but I do not know exactly why