H hyokim07 Member Licensed User Longtime User Jan 27, 2014 #1 Hi, Erel! I am trying to download image from the web with the following input: <div class="img"><img id="imgid48" src="image/Kim_Hyo.jpg" alt="Kim_Hyo" width="220" height="220" onClick="toggleIt('id48a')"><div class="desc" id="name48">Kim Hyo</div><div class="desc" id="id48a">?</div></div> I am trying to use Regex.Matcher. I am lost. Can you please help me? Thank you very much in advance.
Hi, Erel! I am trying to download image from the web with the following input: <div class="img"><img id="imgid48" src="image/Kim_Hyo.jpg" alt="Kim_Hyo" width="220" height="220" onClick="toggleIt('id48a')"><div class="desc" id="name48">Kim Hyo</div><div class="desc" id="id48a">?</div></div> I am trying to use Regex.Matcher. I am lost. Can you please help me? Thank you very much in advance.
Erel B4X founder Staff member Licensed User Longtime User Jan 27, 2014 #2 Hi, Erel! Click to expand... This is a community forum. You should not limit your question to a single member... Which pattern are you trying? Upvote 0
Hi, Erel! Click to expand... This is a community forum. You should not limit your question to a single member... Which pattern are you trying?
H hyokim07 Member Licensed User Longtime User Jan 27, 2014 #3 Erel said: This is a community forum. You should not limit your question to a single member... Which pattern are you trying? Click to expand... OK, I will be careful next time. I just want read the pattern of image names. So I can download image images with the different names from the same source. Thank you in advance. Upvote 0
Erel said: This is a community forum. You should not limit your question to a single member... Which pattern are you trying? Click to expand... OK, I will be careful next time. I just want read the pattern of image names. So I can download image images with the different names from the same source. Thank you in advance.
Erel B4X founder Staff member Licensed User Longtime User Jan 28, 2014 #4 Something like: Code: Dim m As Matcher = Regex.Matcher("src=\""([^""]+)\""", text) Do While m.Find Log(m.Group(1)) Loop Upvote 0
Something like: Code: Dim m As Matcher = Regex.Matcher("src=\""([^""]+)\""", text) Do While m.Find Log(m.Group(1)) Loop
H hyokim07 Member Licensed User Longtime User Jan 29, 2014 #5 Thank you, Erel! I've tried with the following to be able to distinguish with other image files: Dim m As Matcher = Regex.Matcher(""\"" src=\""([^""]+)\""", text) Do While m.Find Log(m.Group(1)) Loop The results were: js/floating.js image/Kim_Hyo.jpg I just need to get the image file name. The html file has a several images with different img id. Is there any way that can extract the bold and underlined one from the below html codes? <div class="img"><img id="imgid48" src="image/Kim_Hyo.jpg" alt="Kim_Hyo" width="220" height="220" onClick="toggleIt('id48a')"><div class="desc" id="name48">Kim Hyo</div><div class="desc" id="id48a">?</div></div> <script type="text/javascript" src="js/floating.js"></script> My desired result should be: image/Kim_Hyo.jpg I hope this is not confusing. Thank you in advance. Upvote 0
Thank you, Erel! I've tried with the following to be able to distinguish with other image files: Dim m As Matcher = Regex.Matcher(""\"" src=\""([^""]+)\""", text) Do While m.Find Log(m.Group(1)) Loop The results were: js/floating.js image/Kim_Hyo.jpg I just need to get the image file name. The html file has a several images with different img id. Is there any way that can extract the bold and underlined one from the below html codes? <div class="img"><img id="imgid48" src="image/Kim_Hyo.jpg" alt="Kim_Hyo" width="220" height="220" onClick="toggleIt('id48a')"><div class="desc" id="name48">Kim Hyo</div><div class="desc" id="id48a">?</div></div> <script type="text/javascript" src="js/floating.js"></script> My desired result should be: image/Kim_Hyo.jpg I hope this is not confusing. Thank you in advance.
DonManfred Expert Licensed User Longtime User Jan 29, 2014 #6 Is it YOUR website you want to get the images from or is it an source from domeone other? If it is yours; you can restructure your html to the desired order inside the img-tag. If it is from another; you should find the right RegEx for HIS img-tag-propertiers-order. That´s the problem. You cannot RegEx a Website, you have to use an DOM-Parser... If it is your website then you also could do that with JavaScript and, if the website is loaded from within a webview with javascript-interface, post the results from Javascript to your App. With JQuery for ex it should be only a few lines of code... $('img').each(function(){ var t=$(this); alert(t.attr('src')); // src }); Click to expand... Please see this example from warwound telling how to inject javascript into a webpage which is loaded in a webview.. Last edited: Jan 29, 2014 Upvote 0
Is it YOUR website you want to get the images from or is it an source from domeone other? If it is yours; you can restructure your html to the desired order inside the img-tag. If it is from another; you should find the right RegEx for HIS img-tag-propertiers-order. That´s the problem. You cannot RegEx a Website, you have to use an DOM-Parser... If it is your website then you also could do that with JavaScript and, if the website is loaded from within a webview with javascript-interface, post the results from Javascript to your App. With JQuery for ex it should be only a few lines of code... $('img').each(function(){ var t=$(this); alert(t.attr('src')); // src }); Click to expand... Please see this example from warwound telling how to inject javascript into a webpage which is loaded in a webview..
H hyokim07 Member Licensed User Longtime User Jan 29, 2014 #7 Thank you very much. I cheated by using the following code and it worked. Do While m.Find If (m.Group(1).IndexOf("image")>-1) Then links.Add(m.Group(1)) End If Loop Thanks for all the help. Upvote 0
Thank you very much. I cheated by using the following code and it worked. Do While m.Find If (m.Group(1).IndexOf("image")>-1) Then links.Add(m.Group(1)) End If Loop Thanks for all the help.