-1

I am trying to get price detail of particular project from URL but I am clueless.

example:-From url (https://www.99acres.com/ppc-2515-residential-apartment-mailer) for project Eden Richmond Enclave i want price 14.22 to 31.15 Lac in range A1.

Below is the code I tried:

Sub test()
Set driver = CreateObject("Selenium.FirefoxDriver")
driver.get "https://www.99acres.com/ppc-2515-residential-apartment-mailer"
Range("A1") = driver.FindElementByXPath("//h1[contains(@class,'font-size15')][contains(text(),'Eden Richmond Enclave')][contains(@class,'product-lrg-box')]").Text
End Sub

Pic

img

below is the html code:-

<div class="pro-text">
                  <div class="product-text-box">
                    <div class="product-heading"><span><img src="https://newprojects.99acres.com/projects/eden_group/eden_richmond_enclave/bb7ttfq9.gif">
                      <h1 class="font-size15">Eden Richmond Enclave                        <p>Narendrapur</p>
                      </h1>
                      </span> </div>
                  </div>
                  <div class="product-text-box">
                    <ul class="product-lrg-box">
                          <li> <span><strong><span class="rupee-font">₹ &nbsp;</span>14.22 to 31.15 Lac</strong></span></li>
                            <li><strong>499-1093 SQFT</strong></li>
       
                      <li><strong>1-3 BHK</strong></li>
                            <li style="width:20% !important;"><strong>December 2020</strong></li>
                       </ul>
                    <div id="tabs" class="tab-link tabs-menu tabs-menu-new">
                      <ul>
                        <li><a href="#294015broch">e-Brochure</a></li>
                           <li><a href="#294015amn">Amenities</a></li>
                            <!--  <li style="width:20% !important;"><a href="#294015floor">Floor Plan</a></li>-->
                              <li style="width:20% !important;"><a href="#294015dir">Directions</a></li>
                         </ul>
                    </div>
                    <span class="enquire-new-bt" id="294015-469203,151100-enquire-new-bt" data-val="2"> <a href="javascript:void(0)">I am Interested</a> </span> </div>
                   </div>
saransh
  • 180
  • 12
  • You're using Selenium and vba? And this needs to be done using firefox? – ashleedawg Jun 05 '18 at 07:54
  • Hi ashleedawg thank for reply,Yes i am using selenium vba with firefox. – saransh Jun 05 '18 at 08:01
  • This URL does not work in UK. And there even seems to be problems with the cached versions. – QHarr Jun 05 '18 at 08:10
  • 1
    Can you show the relevant HTML please. – QHarr Jun 05 '18 at 08:11
  • 1
    And what happened with the above? – QHarr Jun 05 '18 at 08:14
  • 1
    Unless there's a reason you need to use those platforms, I'd suggest you go with just [tag:vba] and use [tag:internet-explorer] for such a straightforward scraping job, If you're interested, here's an [**excellent tutoria**l](https://youtu.be/dShR33CdlY8). IE is pretty standard as a browser for use with VBA. (As a fellow Firefox user, VBA is the only reason I have IE installed. I've looked into using Firefox, and it's *possible* but there isn't a lot of docs/examples available for it.) – ashleedawg Jun 05 '18 at 08:15
  • Try .FindElementByCSS("ul.product-lrg-box") to get the entire string then split out what you want? – QHarr Jun 05 '18 at 08:25
  • Are you after that specific price against `Eden Richmond Enclave` or all the prices available there in that page? – SIM Jun 05 '18 at 09:06

2 Answers2

1

Perhaps try

.FindElementByCSS("ul.product-lrg-box span")

Depends whether you intend to repeat this process for other elements.

For the above, with the HTML you supplied you get:

CSS selector result

Otherwise,

.FindElementByCSS("ul.product-lrg-box")

retrieves the entire string.

Without being able to view the page and knowing if you want to retrieve more elements you might consider

.FindElementsByCss("ul.product-lrg-box span") 

and looping over the collection returned (if valid); or,

Try scraping with IE and using something like:

 IE.documentQuerySelectorAll("ul.product-lrg-box span")

and then looping over the NodeList returned.

QHarr
  • 72,711
  • 10
  • 44
  • 81
  • Hi QHarr thanks for the reply,i have around 5 project in this url and i want only Eden Richmond Enclave project price when i run .FindElementByCss("ul.product-lrg-box span").Text then it pull only first project detail but Eden Richmond Enclave project is located in 2nd position. – saransh Jun 05 '18 at 08:56
  • FindElementsByCss("ul.product-lrg-box span")(1).Text ? – QHarr Jun 05 '18 at 08:57
  • I am guessing because you have another answer you are not bothering to respond to this? – QHarr Jun 05 '18 at 09:30
0

To extract the text 14.22 to 31.15 Lac you can use either of the following Locator Strategies:

  • XPath:

    //h1[contains(.,'Eden Richmond Enclave')]//following::div[1]/ul[@class='product-lrg-box']/li//span/strong[not(@class='rupee-font')]
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217