scrape url out of brackets?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • homepricemaps@gmail.com

    #1

    scrape url out of brackets?

    any idea how to scrape a url out of a file? for instance if i want to
    scrape out the href at the end which is "www.cnn.co m" is there a way to
    do it?

    <tr class="rulesbod y"><td width="183" class="rulesbod y"><a
    href="www.cnn.c om">

  • Mike Meyer

    #2
    Re: scrape url out of brackets?

    homepricemaps@g mail.com writes:
    [color=blue]
    > any idea how to scrape a url out of a file? for instance if i want to
    > scrape out the href at the end which is "www.cnn.co m" is there a way to
    > do it?
    > <tr class="rulesbod y"><td width="183" class="rulesbod y"><a
    > href="www.cnn.c om">[/color]

    BeautifulSoup.

    <mike
    --
    Mike Meyer <mwm@mired.or g> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

    Comment

    • Ravi Teja

      #3
      Re: scrape url out of brackets?

      Regular Expressions are the most common way.
      Source code: Lib/re/ This module provides regular expression matching operations similar to those found in Perl. Both patterns and strings to be searched can be Unicode strings ( str) as well as 8-...


      HTML parser is another


      Comment

      • homepricemaps@gmail.com

        #4
        Re: scrape url out of brackets?

        so you recommend using some sort of for statement with the html parser
        where i tell it to only parse stuff found in the <tr> tag for instance?

        Ravi Teja wrote:[color=blue]
        > Regular Expressions are the most common way.
        > http://docs.python.org/lib/module-re.html
        >
        > HTML parser is another
        > http://docs.python.org/lib/module-htmllib.html[/color]

        Comment

        • homepricemaps@gmail.com

          #5
          Re: scrape url out of brackets?

          so here is the syntax folks!!!

          for anchor in soup.fetch('a', {'target': '_blank'}):
          print anchor['href']



          homepricemaps@g mail.com wrote:[color=blue]
          > so you recommend using some sort of for statement with the html parser
          > where i tell it to only parse stuff found in the <tr> tag for instance?
          >
          > Ravi Teja wrote:[color=green]
          > > Regular Expressions are the most common way.
          > > http://docs.python.org/lib/module-re.html
          > >
          > > HTML parser is another
          > > http://docs.python.org/lib/module-htmllib.html[/color][/color]

          Comment

          Working...