Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Adobe AIR Development

Reply
New Developer
TurboLs1
Posts: 3
Registered: ‎01-09-2011
My Carrier: Verizon

How to load webpage source for parsing?

Hello all, I am new to coding in this environment and am looking for a way to load a webpage source as text so I can parse the data I need. If there is a more efficient method of parsing a webpage, that may work as well. I have tried many methods so far with no success. I am attempting to use the 

QNXStageWebView to display the results of a URLLoader request at the moment, but havent had any success here either. Any suggestions or guidance would be greatly appreciated. Thanks!

 

var loader:URLLoader = new URLLoader();				
var request:URLRequest = new URLRequest("http://google.com");
loader.load(request);
var text:URLVariables = new URLVariables(loader.data);
webView.loadString(text);

 

Please use plain text.
Developer
zezke
Posts: 816
Registered: ‎12-12-2010
My Carrier: Mobile Vikings

Re: How to load webpage source for parsing?

I am not 100% sure what you want to do exactly but if you want to used QNXStageWebView you don't need the URLLoader anymore.

 

 

webView = new QNXStageWebView();
webView.enableCookies = true;
webView.enableJavascript = true;
webView.enableScrolling = true;
webView.addEventListener(Event.COMPLETE, loadWebView);
webView.loadURL(url);

private function loadWebView(event:Event):void{
	webView.autoFit = true;
	webView.stage = stage;
}

 You can find an example usage in the RSS Reader sample.

 

-------------------------------------------
Your like is much appreciated!
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
New Developer
TurboLs1
Posts: 3
Registered: ‎01-09-2011
My Carrier: Verizon

Re: How to load webpage source for parsing?

zezke, thanks for the reply. I am using the URLLoader to get the HTML. I have now figured out how to load the html, but am still working on how to parse the data (im a Visual Basic guy). The webview is used to display a webpage once the user has used my apps menu to navigate to the desired page.

Please use plain text.
Developer
zezke
Posts: 816
Registered: ‎12-12-2010
My Carrier: Mobile Vikings

Re: How to load webpage source for parsing?

I am certainly not a specialist in this area, but I remember reading a topic here saying that it was impossible to get the data loaded from a QNXStageWebView component or to use the data of an URLLoader for the QNXStageWebView component.

 

See these topics:

 

Reading HTML using QNXStageWebView

 

Getting HTML from QNXStageWebView without URLLoader

-------------------------------------------
Your like is much appreciated!
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
studiochris
Posts: 165
Registered: ‎10-26-2010
My Carrier: .

Re: How to load webpage source for parsing?

[ Edited ]

Don't pull it in as a regular string, pull it in as XML so it keeps the structure (or load it as a String and cast it to XML). From there, you can search the nodes with E4X notation.

Please use plain text.
Developer
jtegen
Posts: 6,149
Registered: ‎10-27-2010
My Carrier: AT&T

Re: How to load webpage source for parsing?

I was trying to do this too.  Currently, there is no way to get the raw contents of the QNX web view.  If you really need it, you can get the URL and re-get the data via URLLoader.  For me, I am waiting to get it directly from the control in a "future" release.

Please use plain text.
Regular Contributor
anthonyq
Posts: 73
Registered: ‎12-09-2010
My Carrier: Virgin Mobile USA

Re: How to load webpage source for parsing?

[ Edited ]

After you load it in use the string.split method to manipulate the data you want. Ex:

 

 

var CSVURL:URLRequest = new URLRequest;
CSVURL.url = "http://path/to/url";
CSVURL.useCache = false;
var CSV:URLLoader = new URLLoader;
CSV.load(CSVURL);				CSV.addEventListener(Event.COMPLETE,function(event:Event):void {
	var csvsrc:String = CSV.data.toString();
	var rows:Array = csvsrc.split("\n"); //array with elements=each line
	rows.splice(0,8); //get rid of rows we might not want (optional)
	for each (info in rows) {
		var infoArr:Array = info.split(","); //array of CSV values
		trace ( infoArr[0] ); //or whatever you want to do
	}
}

 

 

 

Anthony
http://www.anthonyquarella.com
Accepted Apps: UpToDateTV
Please use plain text.