Ask Your Question
0

Libreoffice Calc Basic get WebPage page data

asked 2016-06-24 02:03:16 +0100

imrdnm gravatar image

updated 2016-06-24 04:39:29 +0100

The code below is a Microsoft Excel VBA code. What's the LibreOffice Calc Basic equivalent of Set request = CreateObject("MSXML2.XMLHTTP") ? I am running LibreOffice 5.1 in Ubuntu 14.04.

Sub testGet
    Dim request As Object
    Dim response As String
    Dim URL As String

    Set request = CreateObject("MSXML2.XMLHTTP")
    URL = "http://github.com/trending"

    With request
        .Open "GET", URL, False
        .send
        response = .responseText
    End With
End Sub
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2016-06-24 07:30:53 +0100

mauricio gravatar image

With EasyDev, is easy: http://easydev.readthedocs.io/en/late...

Sub Main
    util = createUnoService("org.universolibre.EasyDev")
    data = createUnoStruct("org.universolibre.EasyDev.Requests")

    data.Method = "get"
    data.Url = "http://github.com/trending"
    response = util.requests(data)

    util.fileSave("/home/USER/info.txt", "w", response.Text)

    MsgBox "End"
End Sub

Best regards

edit flag offensive delete link more

Comments

This requires that the user installs EasyDev first right? I was wondering if there was any way that didn't required installing additional software.

imrdnm gravatar imageimrdnm ( 2016-06-24 16:39:01 +0100 )edit

of course, not that I know

I developed EasyDev, because Basic is very poor

Best regards

mauricio gravatar imagemauricio ( 2016-06-24 18:33:46 +0100 )edit
0

answered 2016-06-29 06:27:35 +0100

mark_t gravatar image

updated 2016-06-29 06:42:14 +0100

You could insert a data link to get the web page data into a worksheet.

' Location for the data from the web page.
oAddress = oSheet.getCellByPosition( 0, 0 ).getCellAddress()

' The HTML sections are named HTML_all, HTML_tables, HTML_1, HTML_2, HTML_3, etc.
oDoc.AreaLinks.insertAtPosition( oAddress, url, "HTML_tables", "calc_HTML_WebQuery", "0 0" )

' Following breaks the link, but leaves the data
oDoc.AreaLinks.removeByIndex( 0 )
edit flag offensive delete link more

Comments

I don't see how this code could fetch any data. I have no problem processing html, I just have problem getting everything as text from a URL in the first place.

imrdnm gravatar imageimrdnm ( 2016-06-30 13:12:20 +0100 )edit

If you try it you will see the text from the web page is added to the worksheet, then you can search the worksheet for the data you want.

You see the format from GUI using "Sheet", "Link to External Data ...", then enter the URL, and select the part of the HTML required.

Break the link or change settings from "Edit", "Links...".

mark_t gravatar imagemark_t ( 2016-06-30 17:40:47 +0100 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2016-06-24 02:03:16 +0100

Seen: 1,403 times

Last updated: Jun 29 '16