getting img tag src attribute values from a text file using C#
-
Hi, I have a text file that contains html tags. I like to use C# to read this file and list all the src attributes of tags. I was wondering how I can read through my file and list all of them. Thank you in advance for your time and consideration.
-
Hi, I have a text file that contains html tags. I like to use C# to read this file and list all the src attributes of tags. I was wondering how I can read through my file and list all of them. Thank you in advance for your time and consideration.
Use an existing HTML parser: MIL HTML Parser[^] - let it handle the "donkey work" for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
Use an existing HTML parser: MIL HTML Parser[^] - let it handle the "donkey work" for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
That was a nice project but the problem is my content is coming from a json file, not a single html page.
-
That was a nice project but the problem is my content is coming from a json file, not a single html page.
It would have been nice to include that important little tidbit in your original post. NewtonSoft's JSON library makes it easy to load and parse a JSON file. After that, you can use what OriginalGriff suggested.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak -
It would have been nice to include that important little tidbit in your original post. NewtonSoft's JSON library makes it easy to load and parse a JSON file. After that, you can use what OriginalGriff suggested.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave KreskowiakOh ok, thanks guys, I will give it a try then :thumbsup:
-
It would have been nice to include that important little tidbit in your original post. NewtonSoft's JSON library makes it easy to load and parse a JSON file. After that, you can use what OriginalGriff suggested.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave KreskowiakActually in the end, I found it much easier for the task to be done in Python using the following code:
import urllib
f = urllib.urlopen("URL")
s = f.read()
f.close()from bs4 import BeautifulSoup
soup = BeautifulSoup(s)inputTags = soup.find_all("img", attrs={"src":True})
output = [ x["src"] for x in inputTags ]
print output
And yep I know this is C# forum! :D