Jump to content
Sign in to follow this  
Kinhow

How to get the content of a <spam>Content</spam>?

Recommended Posts

Kinhow

Hi, I'm trying to use the IE.au3 to get this content but I'm not sure how to do this.

Is there a way of doing this using XPath or maybe any other smarter way than reading the _IEBodyReadText and cutting the string?

Share this post


Link to post
Share on other sites
water

You are talking about <span>, right ;)

You can access items by ID or name using _IEGetObjById or _IEGetObjByName if there is an ID or name.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kinhow

Yeah, I meant spaN hehe.

But the thing is that they don't have an ID or NAME.

How can I do that?

Share this post


Link to post
Share on other sites
water

Then I would use something like this:

$sHTML = _IEBodyReadHTML($oIE_object)
$asSPAN = StringSplit($sHTML, "<span>", 1)

You get an array with a <Span> in each element. Strip off the "</span>" from the end of each element. That's it.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kinhow

well, that the way I didnt want to do... because its an specific span in the middle of HTML.

XPath would do the job... but I dont knwo if there is a way to do this with XPath in IE.au3

Share this post


Link to post
Share on other sites
Melba23

Kinhow,

You might be able to do it with a RegEx - can you show us an example of the Html and the specific <span> you wish to extract? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Kinhow

There you go, I want to make a few fake registrations on my website then I found this generator here:

http://fakenamegenerator.com/advanced.php

I wanted to go to the span of the first name, but I want also the birthday info, username etc.

Share this post


Link to post
Share on other sites
Skitty

There you go, I want to make a few fake registrations on my website then I found this generator here:

http://fakenamegenerator.com/advanced.php

I wanted to go to the span of the first name, but I want also the birthday info, username etc.

Something tells me you're really after the email system, it's ok. You can tell us. We don't bite.


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Kinhow

Something tells me you're really after the email system, it's ok. You can tell us. We don't bite.

haha no it's not, its really the random generated info that I am after.

Btw mailinator.com is way better than this one

Share this post


Link to post
Share on other sites
xanathos

Get the page source code with Inetread convert it to string using BinaryToString, then find your span id by using StringInStr (given-name in your case) then from that you can use StringTrimLeft or other that would suit your needs.

Edited by xanathos

Share this post


Link to post
Share on other sites
Kinhow

Get the page source code with Inetread convert it to string using BinaryToString, then find your span id by using StringInStr (given-name in your case) then from that you can use StringTrimLeft or other that would suit your needs.

I'm not sure if you read the part where I ask if there is some other way than this one.

Share this post


Link to post
Share on other sites
water

You have been offered different solutions for your problem but you don't want to accept them. Why?

It looks like there is no XPath based solution available.

I would stick with the solutions that work.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Skitty

I was board and decided to do it with my all time favorite UDF, winhttp. SO you'll need to download that before running this.

#include <Array.au3>
#include ".incWinHttp.au3"
$HTML =  _GetSource("http://fakenamegenerator.com/advanced.php")
If @error Then ConsoleWrite("@Error: " & @error & @CR & _
            "@Extended: " & @extended & @CR & _
            "Return: "&$HTML&@CR)
$Stuff = StringRegExp($HTML,"(?i)<spanb[^>]*>(.*?)</span>",3)
_ArrayDisplay($stuff)
$NAme = StringRegExp(StringStripCR($HTML),'<span class="given-name">(.*?)</span> <span class="additional-name">(.*?)</span> <span class="family-name">(.*?)</span>',3)
If Not @error Then MsgBox(0,"Name",$NAme[0]&" "&$NAme[1]&" "&$NAme[2])

Func _GetSource($url, $Hwnd = '', $Agent = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)')
    Local $Error, $CloseHwnd
    Local $aUrl = _WinHttpCrackUrl($url)
    If @error Then Return SetError(1, @error, False)
    If Not $Hwnd Then
        $CloseHwnd = 1
        $Hwnd = _WinHttpOpen($Agent)
        If @error Then Return SetError(2, @error, False)
        _WinHttpSetTimeouts($Hwnd, 0, 10000, 8000, 5000)
    EndIf
    Local $hConnect = _WinHttpConnect($Hwnd, $aUrl[2])
    If @error Then
        $Error = @error
        _WinHttpCloseHandle($hConnect)
        If $CloseHwnd Then _WinHttpCloseHandle($Hwnd)
        Return SetError(3, $Error, False)
    EndIf
    Local $hRequest = _WinHttpSimpleSEndRequest($hConnect, Default, $aUrl[6] & $aUrl[7])
    If @error Then
        $Error = @error
        _WinHttpCloseHandle($hRequest)
        _WinHttpCloseHandle($hConnect)
        If $CloseHwnd Then _WinHttpCloseHandle($Hwnd)
        Return SetError(4, $Error, False)
    EndIf
    If $hRequest Then
        Local $html = _WinHttpSimpleReadData($hRequest)
        If @error Then
            $Error = @error
            _WinHttpCloseHandle($hRequest)
            _WinHttpCloseHandle($hConnect)
            If $CloseHwnd Then _WinHttpCloseHandle($Hwnd)
            Return SetError(5, $Error, False)
        EndIf
    Else
        _WinHttpCloseHandle($hRequest)
        _WinHttpCloseHandle($hConnect)
        If $CloseHwnd Then _WinHttpCloseHandle($Hwnd)
        Return SetError(6, 0, False)
    EndIf
    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)
    If $CloseHwnd Then _WinHttpCloseHandle($Hwnd)
    Return SetError(0, 0, $html)
EndFunc   ;==>_GetSource
  • Like 1

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
xanathos

I'm not sure if you read the part where I ask if there is some other way than this one.

lol, I don't really see what kind of solution you want, you need to read the page using whatever method which involves opening a socket, so I don't get your point at all...

Share this post


Link to post
Share on other sites
Kinhow

You have been offered different solutions for your problem but you don't want to accept them. Why?

It looks like there is no XPath based solution available.

I would stick with the solutions that work.

The solution of getting the string and cut into various substrings is a possible solution, but I am trying to find another one that could be done with less effort. If I wanted to do manually with text substrings I wouldn't come here to ask you guys for help.

For example ApudAngelorum's solution is a good way using regex, that might help a lot.

lol, I don't really see what kind of solution you want, you need to read the page using whatever method which involves opening a socket, so I don't get your point at all...

I am sorry if I was rude but I just wanted to know if there is a POSSIBLE solution using XPath for example, just like someone did with FF.au3, which is not updated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×