Thursday 16 May 2013 photo 4/4
|
Gjort en "Band Img Finder" till min pirat musik spelare. Den hämtar bilder/bilden från wiki
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
namespace ImgFinder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
List<string> BandImg = new List<string>();
WebClient web = new WebClient();
String html = web.DownloadString("http://sv.wikipedia.org/wiki/" + textBox1.Text);
MatchCollection m1 = Regex.Matches(html, "srcset="//s*(.+?)s*1.5x", RegexOptions.Singleline);
foreach (Match m in m1)
{
string city = m.Groups[1].Value;
BandImg.Add(city);
}
listBox1.DataSource = BandImg;
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "http://" + listBox1.SelectedItem.ToString();
linkLabel1.Text = "http://" + listBox1.SelectedItem.ToString();
}
}
}
</string></string>
//Jag skrev inte </string> </string> i slutet , det är DV som otroligt nog faktist låter mig skriva php/html i text fältet, "med undantag för länkar och liknande"//
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
namespace ImgFinder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
List<string> BandImg = new List<string>();
WebClient web = new WebClient();
String html = web.DownloadString("http://sv.wikipedia.org/wiki/" + textBox1.Text);
MatchCollection m1 = Regex.Matches(html, "srcset="//s*(.+?)s*1.5x", RegexOptions.Singleline);
foreach (Match m in m1)
{
string city = m.Groups[1].Value;
BandImg.Add(city);
}
listBox1.DataSource = BandImg;
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "http://" + listBox1.SelectedItem.ToString();
linkLabel1.Text = "http://" + listBox1.SelectedItem.ToString();
}
}
}
</string></string>
Annons