• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Can't get rid of permission denied error while running my scraper

shahin

Active Member
I've written a script to get phone numbers of different leads populated against each search from a certain webpage. When I run my script, It performs a search in that page by using a searchbox then click on the search button. When the result produces, the scraper goes for each link to click and finally when the destination page appears it parses the phone number and repeat the process. Here is where I'm stuck. My scraper throws "permission denied" error after collecting a single lead. The phone number is available in the source code so there is no need to click on the number to reveal it as it is being shown in the third pics.

Few days back , I encountered the same problem while dealing with another site then sir chihiro advised me to go for using dictionary to get rid of that error and I found it working that time. For some reason I can't make it work here. Any help on this will be highly appreciated.

The search I made in the searchbox is : "Markiser & Persienner" without the quotes.

The script I've tried with:
Code:
Sub Get_Phone()
    Dim HTML As HTMLDocument, posts As Object, ele As Object
    Dim elems As Object, elem As Object, ldic As Object
    Dim post As Object, phnum As Object, key As Variant, URL$

    URL = "https://www.hitta.se/"

    Set ldic = CreateObject("Scripting.Dictionary")

    With New InternetExplorer
        .Visible = True
        .navigate URL
        While .Busy = True Or .readyState < 4: DoEvents: Wend
        Set HTML = .document
    End With

    With HTML
        Do: Set posts = .querySelector("input[name='vad']"): DoEvents: Loop While posts Is Nothing
        posts.Focus
        posts.innerText = "Markiser & Persienner"
        Set post = .querySelector("button[type='submit']")
        post.Click
        Do: Set elem = .getElementsByClassName("result-row__item-hover-visualizer")(0): DoEvents: Loop While elem Is Nothing
    
        For Each ele In .getElementsByClassName("result-row__item-hover-visualizer")
            ldic(ele) = 0
        Next ele
    
        For Each key In ldic.Keys
            key.Click            '''[permission denied error] throws here after being executed once
            Do: Set phnum = HTML.querySelector(".phone-number-hidden__number a.phone-numbers__link strong"): DoEvents: Loop While phnum Is Nothing
            R = R + 1: Cells(R, 1) = phnum.innerText
        Next key
    End With
End Sub

For your consideration, I have attached all the three pages my scraper traverses to collect phone numbers.
 

Attachments

  • first.jpg
    first.jpg
    6.8 KB · Views: 5
  • two.jpg
    two.jpg
    41.3 KB · Views: 6
  • three.jpg
    three.jpg
    18.4 KB · Views: 6
Last edited:
Thanks Marc L, for you suggestion. Yes, I may get the required content using "xmlhttp' request but I am just trying to fix the issue using IE. I believe, there might be any ways to deal with this problem using IE.
 
Back
Top