?
Solved

how to find and get some part of text file

Posted on 2014-03-10
9
Medium Priority
?
410 Views
Last Modified: 2014-04-02
hi, i have an object webbrowser that navigate to one specific url and i want after it loads the url then find the image path that is inside this img tab. so i want to return only the path of the image.

        WebBrowser1.ScriptErrorsSuppressed = True
        WebBrowser1.Navigate("myurl")
        ~~ find and return this value: admin/imagens/bs2314_g.jpg


on the html it will be like this:

<img  class="img_produto" src="admin/imagens/bs2314_g.jpg" />
0
Comment
Question by:rafaelrgl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 8

Expert Comment

by:Mohit Vijay
ID: 39918675
If the image is on server then you get do GetFiles a method from file class and if required you can provide filter also there like *.img etc..
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 39918715
If you do not bother to parse HTML and definitely have 1 image only - you may use simple string processing. Just get document text from the browser and do something like:

            string browserText = "<HTML><img  class=\"img_produto\" src=\"admin/imagens/bs2314_g.jpg\" /></HTML>";
            // find image element
            int imgEleIndex = browserText.IndexOf("<img ");
            //Start searching source
            int srcEleIndex = browserText.IndexOf("src=", imgEleIndex);
            // find closing quote
            int closingQuoteIndex = browserText.IndexOf("\"", srcEleIndex+5);
            // result:
            string pathStr = browserText.Substring(srcEleIndex + 5, closingQuoteIndex - srcEleIndex-5 );
            MessageBox.Show(pathStr);

Open in new window

0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 39918754
What i want to do is mine some data from the page, I have this webbrowse1 Object that opens the page and i want to get the imageurl, and some titles, but i can~t find how to read and retrieve those informations. here is the html code of the page i am reading.
<!DOCTYPE html PUBLIC #-//W3C//DTD XHTML 1.0 Transitional//EN#
#http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd#>

<html xmlns=#http://www.w3.org/1999/xhtml# xml:lang=#pt# lang=#pt#>

<head>

<link href=#css/estilos.css# type=#text/css# rel=#stylesheet# />
<meta http-equiv=#Content-Type# content=#text/html; charset=windows-1252# />
	
<script language=#javascript#>
var url = window.opener.location.href;

  function comprar(codigo, qtde, opcoes)
  {
    if (window.opener != null)
    {
      if (url == window.opener.location.href)
      {
        window.opener.focus();
        window.opener.inserir_item(codigo, qtde, opcoes, );
        setTimeout('window.close()', 10000);
      }
      else
      {
        alert('N¿o ¿ poss¿vel adicionar o item em sua cesta de compras, pois o endere¿o da janela principal da Imagem Folheados foi alterado.');
      }
    }
    else
    {
      alert('N¿o ¿ poss¿vel adicionar o item em sua cesta de compras, pois a janela principal da Imagem Folheados foi fechada.');
      window.close();   
    }
  }
  
  function getOption(select)
  {
    if (select != null)
    {
      return select.value;
    }
    else
      return ##;
  }
</script>



<title>Imagem Folheados - Detalhes do produto</title>
</head>

<body>

<div id=#fundo2#>
	<div id=#geral2#>

			<div id=#conteudo2#>
				<div class=#fundo_cat_sup#>
					<h2>Detalhes do Produto BS2314</h2>
				</div>

				<div id=#detalhes_prod# class=#fundo_cat_meio#>
					<div class=#produto#>
						<h3>C¿digo: BS2314<img alt='NOVO!!!' border='0' src='imagens/novo.gif'></h3>
						<div class=#foto_produto#>
							<img class=#img_novo# border=#0# src=#imagens/novo_etiqueta.gif#>
							<img  class=#img_produto# src=#admin/imagens/bs2314_g.jpg# />	
							          <div class=#div_aviso#>
          <p class=#destaque#><b>ATEN¿¿O:</b><p> <p>Foto ampliada. Veja as dimens¿es mais abaixo.</p>
          </div>	
							
						</div>
						<div class=#dados_produto#>
							<p>red car.</p>
							<div class=#space#></div>
							<p>Pre¿o Atacado: <span class='preco_normal'>R$ 12,85</span>&nbsp;&nbsp;(unid.: par)<br />
								Pre¿o Varejo: <span class='preco_normal'>R$ 25,70</span>&nbsp;&nbsp;(unid.: par)<br />
								Garantia: <span class=#destaque2#>1 ano ap¿s a data da compra</span><br />
								Prazo de Libera¿¿o: <span class=#destaque#>At¿ 48 horas</span> (somente dias ¿teis)
							</p>
								<div class='space'></div><p><strong>Dimens¿es Aproximadas:</strong><br />-comprimento: 1,5 cm<br>-largura: 1,8 cm</p>
							<form id=#form# name=#form#>
								<fieldset>
									<input type=#hidden# name=#direcionar# value=#detalhes_prod2.asp# />
									<input type=#hidden# name=#id# value=#4640# />
									<input type=#hidden# name=#ancora# value=## />
									<input type=#hidden# name=#inserir# value=#sim# />
									<input type=#hidden# name=#detalhes# value=#sim# />
									</p>
									<p>Quantidade na cesta: <span class=#destaque2#><b>--</b></span><br />
									
										<select size=#1# name=#Quantidade#>
											<option selected value=#1#>1</option>
											<option value=#2#>2</option>
											<option value=#3#>3</option>
											<option value=#4#>4</option>
											<option value=#5#>5</option>
											<option value=#6#>6</option>
											<option value=#7#>7</option>
											<option value=#8#>8</option>
											<option value=#9#>9</option>
											<option value=#10#>10</option>
										</select> 
										<img onclick=#comprar(4640, document.form.Quantidade.value, getOption(document.form.Opcoes))# class=#bt_compre# scr=#imagens/bt_compre.gif# border=#0# src=#imagens/bt_compre.gif# alt=#Clique para comprar# width=#75# height=#25# />
																		
								</fieldset>
							</div>
						</form>
					</div>
					<p class=#centro#><input type=#button# value=#Fechar Janela# name=#B3# class=#Button# onclick=#window.close()# /></p>
				</div>
				<div class=#fundo_cat_inf#>
				</div>

<div class='space'></div>
			</div>
			
	</div>
</div>


</body>
	

</html>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 39918837
OK, the document is complex enough and I do not think simple string handling is suitable.
I think you need HTML parsing and looking for proper elements. You can do the search yourself, check something like ".net c# html parsing".
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39921617
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 39933353
Hi, is the agility Pac work on win32 applications because i am getting an error:

Error      1      Reference required to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the base class 'System.Object'. Add one to your project.

i already added the imports system.object and system.runtime and still the same error.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39940202
So yours is a 64bit application?
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 39954398
yeap.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question