Manipulate jQuery to change display length on website

krupster

New Member
Joined
Sep 7, 2017
Messages
1
Hi,

I am currently working on a code in order to scrape data from a Company page in order to make a list of Projects available in Excel (as our programmers are too busy to implement this function directly).
I combined several bits and pieces i found on the web, and it works like a charm, apart from the fact that I cannot manipulate the display length of the data table, which comes preset at 25. However, I need to either display all rows in order for my Macro to Work, or export them to Excel.

The code I have so far:

Code:
Enum READYSTATE
READYSTATE_UNINITIALIZED = 0
READYSTATE_LOADING = 1
READYSTATE_LOADED = 2
READYSTATE_INTERACTIVE = 3
READYSTATE_COMPLETE = 4
End Enum
 

Sub Sektion_110()
 
    'dimension (set aside memory for) our variables
    Dim objIE As InternetExplorer
    Dim ele As Object
    Dim y As Integer
 
    'start a new browser instance
    Set objIE = New InternetExplorer
    'make browser visible
    objIE.Visible = True
 
    'navigate to page with needed data
    objIE.Navigate "[URL]http://staderapport/[/URL]"
    
    'wait for page to load
    Do While objIE.Busy = True Or objIE.READYSTATE <> 4: DoEvents: Loop
    
    With objIE.Document
    .getelementbyid("sektionsNr").selectedindex = -2
    .getelementbyid("reports1").Length 2000
    End With
    y = 1
 
    'look at all the 'tr' elements in the 'table' with id 'reports1',
    'and evaluate each, one at a time, using 'ele' variable
    For Each ele In objIE.Document.getelementbyid("reports1").getelementsbytagname("tr")
        'show the text content of 'tr' element being looked at
        Debug.Print ele.textContent
        'each 'tr' (table row) element contains 4 children ('td') elements
        'put text of 1st 'td' in col A
        Sheets("Sheet1").Range("A" & y).Value = ele.Children(0).textContent
        'put text of 2nd 'td' in col B
        Sheets("Sheet1").Range("B" & y).Value = ele.Children(1).textContent
        'put text of 3rd 'td' in col C
        Sheets("Sheet1").Range("C" & y).Value = ele.Children(2).textContent
        'put text of 4th 'td' in col D
        Sheets("Sheet1").Range("D" & y).Value = ele.Children(3).textContent
        Sheets("Sheet1").Range("E" & y).Value = ele.Children(4).textContent
        Sheets("Sheet1").Range("F" & y).Value = ele.Children(5).textContent
        Sheets("Sheet1").Range("G" & y).Value = ele.Children(6).textContent
        Sheets("Sheet1").Range("H" & y).Value = ele.Children(7).textContent
        Sheets("Sheet1").Range("I" & y).Value = ele.Children(8).textContent
        Sheets("Sheet1").Range("J" & y).Value = ele.Children(9).textContent
        Sheets("Sheet1").Range("K" & y).Value = ele.Children(10).textContent
        Sheets("Sheet1").Range("L" & y).Value = ele.Children(11).textContent
        'increment row counter by 1
        
        y = y + 1
    'repeat until last ele has been evaluated
    Next
 
    'save the Excel workbook
    ActiveWorkbook.Save
 
End Sub

Works like a charm, apart from the line
Code:
.getelementbyid("reports1").Length 2000

The website looks like the Picture:



And the relevant source code:


Code:
var

[SIZE=2] table = $([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'#reports1'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]
        
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] lang = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"da"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
        
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (lang != [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'da'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && lang != [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'en'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) lang = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'en'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]
        oTable = table.dataTable({

 

            bProcessing: 
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
[SIZE=2]
            bServerSide: 
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
[SIZE=2]
            aaSorting: [[0, 
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'asc'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]]],[/SIZE]
[SIZE=2]
            bDestroy: 
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
[SIZE=2]
            iDisplayLength: 25,

            bStateSave: 
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
[SIZE=2]
            language:{ 
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"url"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] : [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"/Scripts/datatable_"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]+lang+[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]".txt"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] },[/SIZE]
[SIZE=2]
 

            lengthMenu: [[10, 25, 50, 2000], [10, 25, 50, 
[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Alle"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]]],[/SIZE]
[SIZE=2]
            stateDuration: -1,
[/SIZE]

I tried to Google a solution for quite a while now, and I am not making any progress. Any help would be apppreciated!

Regards
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,475
Messages
6,125,028
Members
449,205
Latest member
Eggy66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top