Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.Net;
- namespace PullList
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- class Comics
- {
- string title;
- string price;
- }
- // Button1 brings back the current list of comics
- private void button1_Click(object sender, EventArgs e)
- {
- string url = "http://www.previewsworld.com/shipping/newreleases.txt";
- GetList(url);
- Parse(url);
- } // Button 1
- // Button2 brings back the next week's list of comics
- private void button2_Click(object sender, EventArgs e)
- {
- string url = "http://www.previewsworld.com/shipping/upcomingreleases.txt";
- GetList(url);
- } // Button 2
- // Button3 brings back the list of comics 2 weeks out
- private void button3_Click(object sender, EventArgs e)
- {
- string url = "http://www.previewsworld.com/shipping/releasestwoweeks.txt";
- GetList(url);
- } // Button 3
- private void GetList(string URL)
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader sr = new StreamReader(response.GetResponseStream());
- richTextBox1.Text = sr.ReadToEnd();
- sr.Close();
- }
- // From /u/AwwComeOnNow on Reddit
- // http://www.reddit.com/r/learnprogramming/comments/2gv21k/c_looking_for_a_breadcrumb/
- private void Parse(string URL)
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader sr = new StreamReader(response.GetResponseStream());
- string line = "";
- List<Comics> comics = new List<Comics>();
- List<string> _comics = new List<string>();
- while (sr.Peek() != 1) // This will look at the next line and return a -1 if there is no more lines
- {
- line = sr.ReadLine(); // reads the next available line in the file
- _comics.Add(line);
- //MessageBox.Show(line);
- if (line.Contains('\t'))
- {
- string[] linesplit = line.Split('\t'); // Split it into an array, breaking it at the tabs
- // comics.Add(linesplit[1], linesplit[2]); // Add the second value as title and third value as price in the array to a list
- }
- }
- sr.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement