Jump to content

Arrays? (From Website)


Recommended Posts

I'm trying to get an array from a website so that I can just get the url, but I am not sure how. I read a bit of arrays but I have a feeling I'd have to be writing a lot more than what I should be. I will include the script I have so far and the API url for what I want.

 

API: https://api.fast.com/netflix/speedtest?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=1 (I want the 'url' array that contains the url)

 

Code:

#include <MsgBoxConstants.au3>
#include <Inet.au3>
#include <Array.au3>

$site = _INetGetSource('http://api.fast.com/netflix/speedtest?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=1')
MsgBox($MB_SYSTEMMODAL, "Title", $site[1])

 

Link to comment
Share on other sites

Why talk about array ? InetGetSource returns a string so you only need to parse this string using a regular expression or String* funcs  :)

#include <MsgBoxConstants.au3>
#include <Inet.au3>

$json = _INetGetSource('http://api.fast.com/netflix/speedtest?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=1')

$site = StringRegExpReplace($json, '.*(https[^"]+).*', "$1")

MsgBox($MB_SYSTEMMODAL, "Title", $site)

 

Link to comment
Share on other sites

19 hours ago, mikell said:

Why talk about array ? InetGetSource returns a string so you only need to parse this string using a regular expression or String* funcs  :)

#include <MsgBoxConstants.au3>
#include <Inet.au3>

$json = _INetGetSource('http://api.fast.com/netflix/speedtest?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=1')

$site = StringRegExpReplace($json, '.*(https[^"]+).*', "$1")

MsgBox($MB_SYSTEMMODAL, "Title", $site)

 

Thanks, I was going to make it more complicated than it needed to be :P 

Link to comment
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
 Share

×
×
  • Create New...