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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:41:58+00:00 2026-05-24T05:41:58+00:00

I am trying to capture the HTML between a set of <li></li> and put

  • 0

I am trying to capture the HTML between a set of <li></li> and put the captured text in an array.

The way I am trying to parse it is with this Ruby expression:

page.scan(/<li><div class="info">(.*)<\/li>/)

However, for some reason, it returns no matches. What am I doing wrong?

Here is what the HTML looks like:

   <ul class="local">

        <li><div class="info">

    <span class="num">1</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/105111879-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston City Of Boston Housing Authority Main O</a></h2>

      <p><b>Address:</b>
        52 Chauncy St, Boston, MA 02111
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe0" class="rateMe" title="Rate this company">

      <a id="0_1" title="1" ></a>

      <a id="0_2" title="2" ></a>

      <a id="0_3" title="3" ></a>

      <a id="0_4" title="4" ></a>

      <a id="0_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/105111879-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">2</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/105109841-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston Checkcashers INC East Boston</a></h2>

      <p><b>Address:</b>
        19 Maverick Sq, Boston, MA 02128
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe1" class="rateMe" title="Rate this company">

      <a id="1_1" title="1" ></a>

      <a id="1_2" title="2" ></a>

      <a id="1_3" title="3" ></a>

      <a id="1_4" title="4" ></a>

      <a id="1_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/105109841-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">3</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/181884283-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston City Of Boston Housing Authority Develo</a></h2>

      <p><b>Address:</b>
        755 Tremont St, Boston, MA 02118
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe2" class="rateMe" title="Rate this company">

      <a id="2_1" title="1" ></a>

      <a id="2_2" title="2" ></a>

      <a id="2_3" title="3" ></a>

      <a id="2_4" title="4" ></a>

      <a id="2_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/181884283-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">4</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/142710920-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Citizens Bank Phonebank Boston Offices Boston</a></h2>

      <p><b>Address:</b>
        771 Commonwealth Ave, Boston, MA 02215
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe3" class="rateMe" title="Rate this company">

      <a id="3_1" title="1" ></a>

      <a id="3_2" title="2" ></a>

      <a id="3_3" title="3" ></a>

      <a id="3_4" title="4" ></a>

      <a id="3_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/142710920-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">5</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/199373037-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Citizens Bank Phonebank Boston Offices Boston</a></h2>

      <p><b>Address:</b>
        771 Commonwealth Ave, Boston, MA 02215
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe4" class="rateMe" title="Rate this company">

      <a id="4_1" title="1" ></a>

      <a id="4_2" title="2" ></a>

      <a id="4_3" title="3" ></a>

      <a id="4_4" title="4" ></a>

      <a id="4_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/199373037-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">6</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/181906441-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston City Of Boston Housing Authority Develo</a></h2>

      <p><b>Address:</b>
        266 N Beacon St, Brighton, MA 02135
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe5" class="rateMe" title="Rate this company">

      <a id="5_1" title="1" ></a>

      <a id="5_2" title="2" ></a>

      <a id="5_3" title="3" ></a>

      <a id="5_4" title="4" ></a>

      <a id="5_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/181906441-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">7</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/181906436-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston City Of Boston Housing Authority Develo</a></h2>

      <p><b>Address:</b>
        91 Ames St, Dorchester Center, MA 02124
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe6" class="rateMe" title="Rate this company">

      <a id="6_1" title="1" ></a>

      <a id="6_2" title="2" ></a>

      <a id="6_3" title="3" ></a>

      <a id="6_4" title="4" ></a>

      <a id="6_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/181906436-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">8</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/142706974-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston City Of Boston Housing Authority Develo</a></h2>

      <p><b>Address:</b>
        15 Mary Moore Beatty Cir, Mattapan, MA 02126
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe7" class="rateMe" title="Rate this company">

      <a id="7_1" title="1" ></a>

      <a id="7_2" title="2" ></a>

      <a id="7_3" title="3" ></a>

      <a id="7_4" title="4" ></a>

      <a id="7_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/142706974-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">9</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/105111596-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston Handyman For Boston Eastern Massachusetts</a></h2>

      <p><b>Address:</b>
        12 Muldoons Ct, Waltham, MA 02453
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe8" class="rateMe" title="Rate this company">

      <a id="8_1" title="1" ></a>

      <a id="8_2" title="2" ></a>

      <a id="8_3" title="3" ></a>

      <a id="8_4" title="4" ></a>

      <a id="8_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/105111596-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

        <li><div class="info">

    <span class="num">10</span>

  <div style="margin:0 0 0 45px;">

    <h2><a href="/local_detail_l/199782811-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6">Boston Clothing Architect</a></h2>

      <p><b>Address:</b>
        10 Tremont St, Boston, MA 02108
      </p>


      </div>
</div>

<div class="ratingbox">
  <span id="rateMe9" class="rateMe" title="Rate this company">

      <a id="9_1" title="1" ></a>

      <a id="9_2" title="2" ></a>

      <a id="9_3" title="3" ></a>

      <a id="9_4" title="4" ></a>

      <a id="9_5" title="5" ></a>

  </span>

    <div class="not-rated"><a href="/local_detail_l/199782811-ST25/Boston,%20MA/Boston,%20MA?_session_id=73215ec8bd6d1cf4da158da341e450d6#new-review" class="not-rated">Be the first to review!</a></div>

</div>

</li>

    </ul>
  • 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-05-24T05:41:59+00:00Added an answer on May 24, 2026 at 5:41 am

    Firstly read this: RegEx match open tags except XHTML self-contained tags

    Regex: set single line option, use non greedy expression, i.e.:

    (?s)<li><div class="info">(.*?)<\/li>

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

Sidebar

Related Questions

I am trying to capture urls in an html page that is being repeated
I'm trying to parse this HTML block: <div class=v120WrapperInner><a href=/redirect?q=http%3A%2F%2Fwww.google.com%2Faclk%3Fsa%3DL%26ai%3DCKJh--O7tSsCVIKeyoQTwiYmRA5SnrIsB1szYhg2d2J_EAhABIJ7rxQ4oA1CLk676B2DJntmGyKOQGcgBAaoEFk_Qyu5ipY7edN5ETLuchKUCHbY4SA#0%26num%3D1%26sig%3DAGiWqtwtAf8NslosN7AuHb7qC7RviHVg7A%26q%3Dhttp%3A%2F%2Fwww.youtube.com%2Fwatch%253Fv%253D91sYT_8CN8Q%2526feature%253Dpyv%2526ad%253D3409309746%2526kw%253Dsusan%25252#0boyle&amp;adtype=pyv&amp;event=ad&amp;usg=bR7ErKA_3szWtQMGe2lt1dpxzHc= title=The Valley Downs Chicago><img
In the example below I am trying to capture the text between the two
I'm trying to capture dvdauthor's output to a file. So far i found this
I am trying to capture the duration elapsed between touch start and end, and
I'm trying to capture certain parts of HTML using regular expressions, and I've come
I am trying to capture img tag in HTML using Regex... So these must
I'm trying to clean some html text with javascript, there are white spaces included
I am having some trouble trying to capture the rendered html of an elmenet
I trying to capture the target element's id when function fired, but this keyword

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.