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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:38:26+00:00 2026-06-06T12:38:26+00:00

I have some troubles with getting the data from the website. The website source

  • 0

I have some troubles with getting the data from the website. The website source is here:

view-source:http://release24.pl/wpis/23714/%22La+mer+a+boire%22+%282011%29+FRENCH.DVDRip.XviD-AYMO

there’s sth like this:

INFORMACJE O FILMIE

Tytuł……………………………………..: La mer à boire

Ocena………………………………………: IMDB – 6.3/10 (24)

Produkcja…………………………………..: Francja

Gatunek…………………………………….: Dramat

Czas
trwania………………………………..:
98 min.

Premiera……………………………………: 22.02.2012 – Świat

Reżyseria………………………………….: Jacques Maillot

Scenariusz………………………………….: Pierre Chosson, Jacques Maillot

Aktorzy…………………………………….: Daniel Auteuil, Maud Wyler, Yann Trégouët,
Alain Beigel

And I want to get the data from this website to have a Python list of strings:

[[Tytuł, "La mer à boire"]
[Ocena, "IMDB - 6.3/10 (24)"]
[Produkcja, Francja]
[Gatunek, Dramat]
[Czas trwania, 98 min.]
[Premiera, "22.02.2012 - Świat"]
[Reżyseria, "Jacques Maillot"]
[Scenariusz, "Pierre Chosson, Jacques Maillot"]
[Aktorzy, "Daniel Auteuil, Maud Wyler, Yann Trégouët, Alain Beigel"]]

I wrote some code using BeautifulSoup but I cant go any further, I just don’t know what to get the rest from the website source and how to convert is to string …
Please, help!

My code:

    # -*- coding: utf-8 -*-
#!/usr/bin/env python

import urllib2
from bs4 import BeautifulSoup

try :
    web_page = urllib2.urlopen("http://release24.pl/wpis/23714/%22La+mer+a+boire%22+%282011%29+FRENCH.DVDRip.XviD-AYMO").read()
    soup = BeautifulSoup(web_page)
    c = soup.find('span', {'class':'vi'}).contents
    print(c)
except urllib2.HTTPError :
    print("HTTPERROR!")
except urllib2.URLError :
    print("URLERROR!")
  • 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-06T12:38:28+00:00Added an answer on June 6, 2026 at 12:38 pm

    The secret of using BeautifulSoup is to find the hidden patterns of your HTML document. For example, your loop

    for ul in soup.findAll('p') :
        print(ul)
    

    is in the right direction, but it will return all paragraphs, not only the ones you are looking for. The paragraphs you are looking for, however, have the helpful property of having a class i. Inside these paragraphs one can find two spans, one with the class i and another with the class vi. We are lucky because those spans contains the data you are looking for:

    <p class="i">
        <span class="i">Tytuł............................................</span>
        <span class="vi">: La mer à boire</span>
    </p>
    

    So, first get all the paragraphs with the given class:

    >>> ps = soup.findAll('p', {'class': 'i'})
    >>> ps
    [<p class="i"><span class="i">Tytuł... <LOTS OF STUFF> ...pan></p>]
    

    Now, using list comprehensions, we can generate a list of pairs, where each pair contains the first and the second span from the paragraph:

    >>> spans = [(p.find('span', {'class': 'i'}), p.find('span', {'class': 'vi'})) for p in ps]
    >>> spans
    [(<span class="i">Tyt... ...</span>, <span class="vi">: La mer à boire</span>), 
     (<span class="i">Ocena... ...</span>, <span class="vi">: IMDB - 6.3/10 (24)</span>),
     (<span class="i">Produkcja.. ...</span>, <span class="vi">: Francja</span>),
     # and so on
    ]
    

    Now that we have the spans, we can get the texts from them:

    >>> texts = [(span_i.text, span_vi.text) for span_i, span_vi in spans]
    >>> texts
    [(u'Tytu\u0142............................................', u': La mer \xe0 boire'),
     (u'Ocena.............................................', u': IMDB - 6.3/10 (24)'),
     (u'Produkcja.........................................', u': Francja'), 
      # and so on
    ]
    

    Those texts are not ok still, but it is easy to correct them. To remove the dots from the first one, we can use rstrip():

    >>> u'Produkcja.........................................'.rstrip('.')
    u'Produkcja'
    

    The : string can be removed with lstrip():

    >>> u': Francja'.lstrip(': ')
    u'Francja'
    

    To apply it to all content, we just need another list comprehension:

    >>> result = [(text_i.rstrip('.'), text_vi.replace(': ', '')) for text_i, text_vi in texts]
    >>> result
    [(u'Tytu\u0142', u'La mer \xe0 boire'),
     (u'Ocena', u'IMDB - 6.3/10 (24)'),
     (u'Produkcja', u'Francja'),
     (u'Gatunek', u'Dramat'),
     (u'Czas trwania', u'98 min.'),
     (u'Premiera', u'22.02.2012 - \u015awiat'),
     (u'Re\u017cyseria', u'Jacques Maillot'),
     (u'Scenariusz', u'Pierre Chosson, Jacques Maillot'),
     (u'Aktorzy', u'Daniel Auteuil, Maud Wyler, Yann Tr&eacute;gou&euml;t, Alain Beigel'),
     (u'Wi\u0119cej na', u':'),
     (u'Trailer', u':Obejrzyj zwiastun')]
    

    And that is it. I hope this step-by-step example can make the use of BeautifulSoup clearer for you.

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

Sidebar

Related Questions

I have some troubles with receiving data on server side. Here goes the code:
I am having trouble getting some data from a JSON object which I have
I have some troubles while writing logs from log4net to the file. I seem
I'm having some troubles with binding data. I have an application that contains a
I'm getting data from an array. For some reason the array has key values
I'm having nice first days using Yii but have some troubles with getting things
I am getting some data from the net, which gets parsed with JSoup in
Some specific situation: I have two Activities . FirstActivity loads data from network(~100 kb)
Im having some trouble getting the syntax right. I have a movie clip that
I have some troubles with positioning my label/password field. With this code they both

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.