Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:59:16+00:00 2026-06-11T19:59:16+00:00

I have pieced together the following script to generate a daily report on a

  • 0

I have pieced together the following script to generate a daily report on a remote Asterisk / Vicidial server. The script grabs the source from the report, performs some formatting, saves the result as a text file and then sends it via smtp to my boss for review. I’m currently running the script on a cron job locally and it works perfectly, however I would like to be able to run it on my VPS; problem being, the script pops a Firefox window and the VPS does not have X or any sort of GUI, and consequently, Firefox will not open, and the data cannot be retrieved.

Just to clarify, I have Firefox and all required modules installed and the VPS is essentially identical to my local machine, bar X and GUI (Debian Lenny).

If some someone could provide any sort of help on how to modify this script in order to work without X / GUI, it would be greatly appreciated!

Thanks, Toby.

import contextlib
import selenium.webdriver as webdriver
import lxml.html as LH
import lxml.html.clean as clean
import csv 
import sys
import smtplib
from email.mime.text import MIMEText
import email.mime.application
import email
import mimetypes
import datetime

date=datetime.date.today()

url="http://myuser:mypass@ipaddress"+ str(date) + "some_other_string"

ignore_tags=('script','noscript','style')
with contextlib.closing(webdriver.Firefox()) as browser:
    browser.get(url)
    content=browser.page_source
    cleaner=clean.Cleaner()
    content=cleaner.clean_html(content)    
    with open('vicidial_data.html','w') as f:
       f.write(content.encode('utf-8'))
    doc=LH.fromstring(content)
    with open('grab_raw.txt','w') as f:
        for elt in doc.iterdescendants():
            if elt.tag in ignore_tags: continue
            text=elt.text or ''
            tail=elt.tail or ''
            words=' '.join((text,tail)).strip()
            if words:
                words=words.encode('utf-8')
                f.write(words+'\n') 

grab=open( 'grab_raw.txt', 'r' )
grab_list=grab.readlines()
grab.close()
del grab_list[0:21]
grab_out=open("Vicidial_Report-"+str(date)+".txt", 'w')
grab_out.writelines(grab_list)
grab_out.close()

msg=email.mime.Multipart.MIMEMultipart()
msg['Subject']='Vicidial call-report' 
msg['From']='me@mycomapny.com'
msg['To']='myboss@mycompany.com'

body = email.mime.Text.MIMEText("Please find attached call-report for " + str(date))
msg.attach(body)

filename= "Vicidial_Report-"+str(date)+".txt"
fp=open(filename,'rb')
att = email.mime.application.MIMEApplication(fp.read(),_subtype="text")
fp.close()
att.add_header('Content-Disposition','attachment',filename=filename)
msg.attach(att)

s = smtplib.SMTP('smtp.gmail.com')
s.starttls()
s.login('mygmaillogin@mycompanydomain.com','mypassword')
s.sendmail('me@mycompanydomain.com',['myboss@mycompanydomain.com', 'someoneelse@mycompanydomain.com', ],     msg.as_string())
s.quit()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:59:17+00:00Added an answer on June 11, 2026 at 7:59 pm

    Corey Goldberg explains how to do this using pyvirtualdisplay.

    You’ll need to be able to install pyvirtualdisplay, xvfb, and xserver-xephyr, however.

    import contextlib
    import selenium.webdriver as webdriver
    display = pyvirtualdisplay.Display(visible = False, size = (800, 600))
    display.start()
    with contextlib.closing(webdriver.Firefox()) as driver:    
        driver.get('http://www.google.com')
        print driver.title
        # Google
    display.stop()
    

    On Ubuntu/Debian the necessary packages can be installed with

    sudo apt-get install python-setuptools
    sudo apt-get install xvfb
    sudo apt-get install xserver-xephyr
    sudo easy_install pyvirtualdisplay
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi step wizard that I have pieced together from useful posts
I have a chained dropdown box that pieces together a download string from a
I have a Python script that downloads a GRIB file (weather forecast data) from
So i have pieced together a couple of other peoples code to get it
I've pieced together some code to use in ASP.NET to prevent controls from losing
So I pieced together this little script to dump all users in Active Directory
So after scouring the Internet I pieced together the following code to upload a
I've looked around and have bits and pieces but can't put the puzzle together.
I have a piece of code like this: <div id=container runat=server> <div id=parent runat=server>
So we have a PHP+Zend Framework+Doctrine 1.2 application that has the following structure: Controller

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.