Kinhow Posted May 28, 2012 Share Posted May 28, 2012 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? Link to comment Share on other sites More sharing options...
water Posted May 28, 2012 Share Posted May 28, 2012 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Kinhow Posted May 28, 2012 Author Share Posted May 28, 2012 Yeah, I meant spaN hehe. But the thing is that they don't have an ID or NAME. How can I do that? Link to comment Share on other sites More sharing options...
water Posted May 28, 2012 Share Posted May 28, 2012 (edited) 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 May 28, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Kinhow Posted May 28, 2012 Author Share Posted May 28, 2012 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2012 Moderators Share Posted May 28, 2012 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Kinhow Posted May 28, 2012 Author Share Posted May 28, 2012 There you go, I want to make a few fake registrations on my website then I found this generator here:http://fakenamegenerator.com/advanced.phpI wanted to go to the span of the first name, but I want also the birthday info, username etc. Link to comment Share on other sites More sharing options...
Skitty Posted May 28, 2012 Share Posted May 28, 2012 There you go, I want to make a few fake registrations on my website then I found this generator here:http://fakenamegenerator.com/advanced.phpI 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. Link to comment Share on other sites More sharing options...
Kinhow Posted May 28, 2012 Author Share Posted May 28, 2012 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 Link to comment Share on other sites More sharing options...
xanathos Posted May 29, 2012 Share Posted May 29, 2012 (edited) 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 May 29, 2012 by xanathos Link to comment Share on other sites More sharing options...
Kinhow Posted May 29, 2012 Author Share Posted May 29, 2012 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. Link to comment Share on other sites More sharing options...
water Posted May 29, 2012 Share Posted May 29, 2012 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Skitty Posted May 29, 2012 Share Posted May 29, 2012 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. expandcollapse popup#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 Kinhow 1 Link to comment Share on other sites More sharing options...
xanathos Posted May 29, 2012 Share Posted May 29, 2012 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... Link to comment Share on other sites More sharing options...
Kinhow Posted May 29, 2012 Author Share Posted May 29, 2012 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now