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 8014769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:02:36+00:00 2026-06-04T20:02:36+00:00

tl;dr: I’m looking for a way to find entries in our database which are

  • 0

tl;dr: I’m looking for a way to find entries in our database which are missing information, getting that information from a website and adding it to the database entry.


We have a media management program which uses a mySQL table to store the information. When employees download media (video files, images, audio files) and import it into the media manager they are suppose to also copy the description of the media (from the source website) and add it to the description in the Media Manager. However this has not been done for thousands of files.

The file name (eg. file123.mov) is unique and the details page for that file can be accessed by going to a URL on the source website:

website.com/content/file123

The information we want to scrape from that page has an element ID which is always the same.

In my mind the process would be:

  1. Connect to database and Load table
  2. Filter: "format" is "Still Image (JPEG)"
  3. Filter: "description" is "NULL"
  4. Get first result
  5. Get "FILENAME" without extension)
  6. Load the URL: website.com/content/FILENAME
  7. Copy contents of the element "description" (on website)
  8. Paste contents into the "description" (SQL entry)
  9. Get 2nd result
  10. Rinse and repeat until last result is reached

My question(s) are:

  1. Is there software that could perform such a task or is this something that would need to be scripted?
  2. If scripted, what would be the best type of script (eg could I achieve this using AppleScript or would it need to be made in java or php etc.)
  • 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-04T20:02:40+00:00Added an answer on June 4, 2026 at 8:02 pm

    I too am not aware of any existing software packages that will do everything you’re looking for. However, Python can connect to your database, make web requests easily, and handle dirty html. Assuming you already have Python installed, you’ll need three packages:

    • MySQLdb for connecting to the database.
    • Requests for easily making http web requests.
    • BeautifulSoup for robust parsing of html.

    You can install these packages with pip commands or Windows installers. Appropriate instructions are on each site. The whole process won’t take more than 10 minutes.

    import MySQLdb as db
    import os.path
    import requests
    from bs4 import BeautifulSoup
    
    # Connect to the database. Fill in these fields as necessary.
    
    con = db.connect(host='hostname', user='username', passwd='password',
                     db='dbname')
    
    # Create and execute our SELECT sql statement.
    
    select = con.cursor()
    select.execute('SELECT filename FROM table_name \
                    WHERE format = ? AND description = NULL',
                   ('Still Image (JPEG)',))
    
    while True:
        # Fetch a row from the result of the SELECT statement.
    
        row = select.fetchone()
        if row is None: break
    
        # Use Python's built-in os.path.splitext to split the extension
        # and get the url_name.
    
        filename = row[0]
        url_name = os.path.splitext(filename)[0]
        url = 'http://www.website.com/content/' + url_name
    
        # Make the web request. You may want to rate-limit your requests
        # so that the website doesn't get angry. You can slow down the
        # rate by inserting a pause with:
        #               
        # import time   # You can put this at the top with other imports
        # time.sleep(1) # This will wait 1 second.
    
        response = requests.get(url)
        if response.status_code != 200:
    
            # Don't worry about skipped urls. Just re-run this script
            # on spurious or network-related errors.
    
            print 'Error accessing:', url, 'SKIPPING'
            continue
    
        # Parse the result. BeautifulSoup does a great job handling
        # mal-formed input.
    
        soup = BeautifulSoup(response.content)
        description = soup.find('div', {'id': 'description'}).contents
    
        # And finally, update the database with another query.
    
        update = db.cursor()
        update.execute('UPDATE table_name SET description = ? \
                        WHERE filename = ?',
                       (description, filename))
    

    I’ll warn that I’ve made a good effort to make that code “look right” but I haven’t actually tested it. You’ll need to fill in the private details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.