Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi can you help me to grab a portion of webpage via regex. Below is what I am trying to do
<div class="fk-srch-item fk-inf-scroll-item"> <div class="line fksd-bodytext "> <div class="unit left fk-sitem-image-section"> <div class="line"> <div class="unit num fksd-smalltext"> <span class="sno-div">1.</span> </div> <div class="lastUnit rposition"> <a href="/software-engineering-practitioner-s-approach +-7th/p/itmczynwvwmjatgq?pid=9780071267823&query=Roger+Pressman&srno=s +_1&ref=1d31579d-d54b-4c3e-8abf-100b33486a91&otracker=from-search"> <img onerror="img_onerror(this);" +data-error-url="http://img1.flixcart.com/img/thumb/book.jpg" height=" +100" width="100" data-src="http://img7.flixcart.com/image/book/8/2/3/ +software-engineering-a-practioner-s-approach-100x100-imad96yhpzgnapyz +.jpeg" src="http://img6.flixcart.com/www/prod/images/gray_1x1-8185705 +5.gif" onload="lzld(this)" alt="Buy Book Software Engineering : A Pra +ctitioner's Approach 7th Edition by " title="Software Engineering : A + Practitioner's Approach 7th Edition by "></img> </a> </div> </div> </div> <div class="line bmargin10"> <h2 class="fk-srch-item-title fksd-bodytext unboldtext"><a + href="/software-engineering-practitioner-s-approach-7th/p/itmczynwvw +mjatgq?pid=9780071267823&query=Roger+Pressman&srno=s_1&ref=1d31579d-d +54b-4c3e-8abf-100b33486a91&otracker=from-search" class="fk-srch-title +-text fksd-bodytext">Software Engineering : A Practitioner's Approach + 7th Edition (Paperback)</a></h2> <span class='fk-item-authorinfo-text fksd-smalltext'>by <a hr +ef="/author/roger-pressman?query=Roger+Pressman&vertical=books&otrack +er=from-search"><b>Roger</b> <b>Pressman</b></a></span>

below is code I am currently using to fetch the portion.
while($page =~m/class="lastUnit.*\n.*\s+.*\n.*\n.*\n.*\n/ig) { print "sample Text\n" }
The code is currently used to fetch a portion of page from class = lastUnit to class = line margin10
can anyone suggest a good regex for selecting the above section

In reply to How to grab a portion of file with regex by romy_mathew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2024-04-19 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found