Get phone number from WebPage

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Get phone number from WebPage

24 Aug 2015, 17:26

Hi!
I want to get phone number from this Web Page without using ComObjCreate("InternetExplorer.Application").
There is javascript which changes digits in random order - I can not understand algorithm.
Please help me with this puzzle.
http://www.doska.ru/msg/work/courses-ed ... ailoo.html

Code: Select all

WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", "http://www.doska.ru/msg/work/courses-education/seminari-un-trenini/ailoo.html", false)
WebRequest.Send()
Body := WebRequest.ResponseBody
pArr := ComObjValue(Body)
cBytes := NumGet(pArr+0, A_PtrSize = 8? 24:16, "uint")
pText := NumGet(pArr+0, A_PtrSize = 8? 16:12, "ptr")
var := StrGet(pText, cBytes, "utf-8")
RegExMatch(var, "id=""ph_td_2"">(.+?)</span>", phone)
msgbox % phone1
Azevedo
Posts: 81
Joined: 07 Feb 2014, 11:35

Re: Get phone number from WebPage

24 Aug 2015, 18:00

Well, since the actual phone number is generated by a javascript, your WebRequest object will only give the initial html file, not the one the scripts modify (like what you see in the browser).

The script that generates your phone number seems to be:

Code: Select all

<script type="text/javascript">open_stat_lnk("");change_price( 8, 0, "", 0 );show_banner( );
var show_code = "Наберите текст с картинки"; var show_phone = "Показать номер"; var pcc_id=0;
print_phone(PH_2,2,0);if( PH_c && !pcc_id ){pcc_id=2;eval(PH_c);}
</script>
Specifically the function: print_phone(PH_2,2,0)
Now to you get what you want, find which actual script have this function and see how print_phone(PH_2,2,0) works.

Good lucky.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Get phone number from WebPage

24 Aug 2015, 19:01

I find it but can not understand:

Code: Select all

function print_phone(d,k,b){var g=el("ph_td_"+k);if(!g){g=el("ph_td")}if(!g||!d){return}var f=p2=_js_decode(d);if(b){var c=el("ptd2_"+k);if(c){c=c.innerHTML;c=c.split("<");c=c[0];c=c.replace("(","");c=c.replace(")","");p2=f.replace("-","");p2=p2.replace("-","");p2=p2.replace("-","");p2=c+""+p2}g.innerHTML='<a href="tel:'+p2+'">'+f+"</a>"}else{g.innerHTML=f}g.style.visibility="visible"}
http://i.doska.ru/w_inc/js/main.ru.doska.js?v=251
Azevedo
Posts: 81
Joined: 07 Feb 2014, 11:35

Re: Get phone number from WebPage

24 Aug 2015, 19:43

Here is a beautified version:

Code: Select all

function print_phone(d, k, b) {
	var g = el("ph_td_" + k);
	if (!g) {
		g = el("ph_td")
	}
	if (!g || !d) {
		return
	}
	var f = p2 = _js_decode(d);
	if (b) {
		var c = el("ptd2_" + k);
		if (c) {
			c = c.innerHTML;
			c = c.split("<");
			c = c[0];
			c = c.replace("(", "");
			c = c.replace(")", "");
			p2 = f.replace("-", "");
			p2 = p2.replace("-", "");
			p2 = p2.replace("-", "");
			p2 = c + "" + p2
		}
		g.innerHTML = '<a href="tel:' + p2 + '">' + f + "</a>"
	} else {
		g.innerHTML = f
	}
	g.style.visibility = "visible"
}
Try StackOverflow.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Get phone number from WebPage

24 Aug 2015, 19:56

What do You mean by StackOverflow?
I do not know javascript. :(
gilliduck
Posts: 265
Joined: 06 Oct 2014, 15:01

Re: Get phone number from WebPage

24 Aug 2015, 20:55

StackOverflow is a website, they're more suited to help you figure out that type of code.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], peter_ahk and 307 guests