-
Jun 26th, 2016, 03:27 AM
#1
Thread Starter
Fanatic Member
Can't get RSS Feed (XML)
Hi All,
Im playing around with getting RSS feed data (XML of course) so I can stay up to date.
I have read countless google results about getting it either straight into XMLreader (would be nice) or otherwise.
Every time I tried doing it the reader would tell me that hexadecimal value xxxx is invalid and die.
I decided to try and get the data to see whats going on and its all garbage I don't know why I cant get the XML.
If you grab the link and paste into a browser it shows the XML just fine.
The code I have to just look at it is
Code:
Dim t As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
Dim wc As New WebClient
Dim j As String = wc.DownloadString(t)
TextBox1.Text = j
Now instead of returning a nice page of XML I get all sorts of random data like below. Im not sure whats going on but I have tried adding headers, using requests instead of webclient, all come out the same. I know its possible, if you head to any online XML validation service they can load and parse it just fine. I just don't know where im going wrong.
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Jun 26th, 2016, 04:17 AM
#2
Re: Can't get RSS Feed (XML)
Try this:
Code:
Dim t As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
Dim wc As New WebClient
Dim j As String = wc.DownloadString(t)
TextBox1.Text = XDocument.Parse(j).ToString
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 26th, 2016, 06:19 AM
#3
Re: Can't get RSS Feed (XML)
It looks like it is encrypted. When I browse to the link and look at the source it looks like XML.
paul - Tried your code and it did not work for me.
-
Jun 26th, 2016, 01:04 PM
#4
Re: Can't get RSS Feed (XML)
Well,
I just tried your link using the WebBrowser control.
VB.NET Code:
webBrowser1.Navigate("https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1")
DocumentCompleted Event
VB.NET Code:
Private Sub webBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs) Dim webBrowser As WebBrowser = CType(sender, WebBrowser) Dim source As String = webBrowser.DocumentText TextBox1.Text = source End Sub
I did get the source but in HTML format/with HTML tags. The feed content is there, except that you need some sort of cleanup to extract the XML/RSS feed.
- kgc
Last edited by KGComputers; Jun 26th, 2016 at 01:37 PM.
-
Jun 26th, 2016, 06:17 PM
#5
Re: Can't get RSS Feed (XML)
It's just that it's GZip encoded.
Code:
Dim url As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
Dim xml As String
Try
Using wc As New WebClient
Using wcStream As IO.Stream = wc.OpenRead(url)
Using gzStream As New IO.Compression.GZipStream(wcStream, IO.Compression.CompressionMode.Decompress)
Using reader As New StreamReader(gzStream)
xml = reader.ReadToEnd
End Using
End Using
End Using
End Using
TextBox1.Text = xml
Catch ex As Exception
MsgBox(ex)
End Try
-
Jun 26th, 2016, 07:00 PM
#6
Re: Can't get RSS Feed (XML)
Slightly modified version of Inferrd's code.
Code:
Dim url As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
Dim rssXE As XElement
Try
Using wc As New Net.WebClient
Using wcStream As IO.Stream = wc.OpenRead(url)
Using gzStream As New IO.Compression.GZipStream(wcStream, IO.Compression.CompressionMode.Decompress)
Using reader As New StreamReader(gzStream)
rssXE = XElement.Load(reader)
End Using
End Using
End Using
End Using
Catch ex As Exception
Debug.WriteLine(ex)
End Try
-
Jul 3rd, 2016, 04:26 AM
#7
Thread Starter
Fanatic Member
Re: Can't get RSS Feed (XML)
hi all, sorry for late reply. yes it seems its just gzip encoded. thanks for all the help. that stumped me for like a whole day.
any way to tell if something is Gzip encoded?
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Jul 3rd, 2016, 06:07 AM
#8
Re: Can't get RSS Feed (XML)
any way to tell if something is Gzip encoded?
Using Mozilla Firebug, Go to Net Tab -> All -> Expand the URL -> Headers -> Expand the Response Headers. There's a property called Content-Encoding.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|