How can i get all links from html file ?
I tried some code:
List<string> metas = new List<string>();
string text = "";
string mys = "";
public List<string> LockedThreads(string filename)
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(filename, Encoding.UTF8);
var metaTags = doc.DocumentNode.SelectNodes("//meta");
if (metaTags != null)
foreach (var tag in metaTags)
if (tag.Attributes["name"] != null && tag.Attributes["content"] != null)
text = tag.Attributes["name"].Value;
mys = tag.Attributes["content"].Value;
var linksOnPage = from lnks in doc.DocumentNode.Descendants()
where lnks.Name == "a" &&
lnks.Attributes["href"] != null &&
lnks.InnerText.Trim().Length > 0
select new
Url = lnks.Attributes["href"].Value,
Text = lnks.InnerText
foreach (HtmlNode node in doc.DocumentNode
.SelectNodes("//a/@href | //img/@src"))
metas.Add(node.Name);
In the var linksOnPage i'm getting all the links but some of them not only links for example the first item i see:
[0] = { Url = "/", Text = " " }
Then the second item:
[1] = { Url = "http://rotter.net/cgi-bin/forum/dcboard.cgi?az=login", Text = "התחבר" }
Next i want to add another loop or variable that will contain only the links after im src for example:
<img
src="http://mysite.com"
border="0"></a></TD><TD
ALIGN="right"
VALIGN="TOP"
WIDTH="55%">
So to get only http://mysite.com
So in the end i will have two Lists:
First List will contain all links from the html file.
Second List only links that are in img src
Ok i'm using regex now and i can get the links i need:
List<string> metas = new List<string>();
List<string> metas1 = new List<string>();
string text = "";
string mys = "";
public List<string> LockedThreads(string filename)
string[] fall = File.ReadAllLines(filename);
foreach (string hh in fall)
if (hh.Contains("http://rotter.net") && hh.Contains("locked")||
hh.Contains("locked_icon_general") ||
hh.Contains("locked_icon_anchor") ||
hh.Contains("icon_anchor") ||
hh.Contains("locked_icon_fire") ||
hh.Contains("locked_icon_sport")||
hh.Contains("locked_icon_camera")||
hh.Contains("locked_icon_movie"))
Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
foreach (Match m in linkParser.Matches(hh))
metas.Add(m.Value);
So now in the metas i have in this case two links.
For example the first link is from this block in the file:
The link i got is : http://rotter.net/forum/Images/hot_icon_anchor.gif
And this is the right link from this block but now how do i get the text from this block and how i connect how do i know that this text belong to the link ? I need to add this text from this block to a new List. Before all that i counted on my own lines
and got the text but that's a bad idea.
I need somehow to get: שרשור תשדירי בחירות מרוכז:
To get the text between the ToolTip',' and the second ',' but not from all the html file only in places of this two links i extracted.
<TD ALIGN="RIGHT"
VALIGN="TOP">
<body onmousemove="overhere()">
<a onmouseover="EnterContent('ToolTip','שרשור תשדירי בחירות מרוכז:','<u><span style=color:#000099;>כתב: menahem בתאריך: 03.03.15
שעה: 08:51</span></u><br>1.<br>http://youtu.be/utUaqyiRkJ8<br><br><br>...'); Activate();"
onmouseout="deActivate()"
href="javascript:void(0)">
<img src="http://rotter.net/forum/Images/hot_icon_anchor.gif"
border="0"></a></TD><TD
ALIGN="right"
VALIGN="TOP"
WIDTH="55%">
<FONT CLASS='text15bn'><FONT
FACE="Arial">
<a href="http://rotter.net/cgi-bin/forum/dcboard.cgi?az=read_count&om=187966&forum=scoops1"><b>
<font color="red">שרשור תשדירי בחירות מרוכז:</b>
</a></font></TD>
Similar Messages
-
How can i get all values from jtable with out selecting?
i have one input table and two output tables (name it as output1, output2). Selected rows from input table are displayed in output1 table. The data in output1 table is temporary(means the dat wont store in database just for display purpose).
Actually what i want is how can i get all values from output1 table to output2 table with out selecting the data in output1 table?
thanks in advance.
rajaYou could set the table's data model to be the same:
output2.setModel( output1.getModel() ); -
How can I get all photos from iPhoto to automatically back up to iCloud from my Mac OSX Version 10.6.8 operating system. Not enough memory to upgrade.
You can't. iCloud is not for general file backup from a Mac. It's for backup up and syncing data between mobile devices and and Macs and The following is from this Apple document: iCloud: Backup and restore overview.
iCloud automatically backs up the most important data on your (mobile) device using iOS 5 or later. Once you have enabled Backup on your iPhone, iPad, or iPod touch .....
What is backed up
You get unlimited free storage for:
Purchased music, movies, TV shows, apps, and books
Notes: Backup of purchased music is not available in all countries. Backups of purchased movies and TV shows are U.S. only. Previous purchases may not be restored if they are no longer in the iTunes Store, App Store, or iBookstore.
Some previously purchased movies may not be available in iTunes in the Cloud. These movies will indicate that they are not available in iTunes in the Cloud on their product details page in the iTunes Store. Previous purchases may be unavailable if they have been refunded or are no longer available in the iTunes Store, App Store, or iBookstore.
You get 5 GB of free iCloud storage for:
Photos and videos in the Camera Roll
Device settings (for example: Phone Favorites, Wallpaper, and Mail, Contacts, Calendar accounts)
App data
Home screen and app organization
Messages (iMessage, SMS, and MMS)
Ringtones
Visual Voicemails
But not from a Mac. If you want to backup your photos and other important files I suggest you get an external hard drive and use it with Time Machine.
OT -
How can I get all photos from the camera roll, and all new pictures taken, to get on the photostream so they can share between iphone and ipad?
When turning PhotoStream on with photos available in the Camera Roll, only photos captured by the iPhone or saved on the iPhone are placed in the PhotoStream.
For all photos that were in the Camera Roll prior to turning PhotoStream on, import the photos with your computer and add the photos to your PhotoStream on your computer. -
How can I get all tracks from an album into the album in my library?
When importing the albums from a folder, the tracks for some of the albums were split up. How can I get them in one?
Hello JudyD276
The article below will give the steps to get the songs grouped together for you.
Why aren't songs with the same album art grouped together?
http://support.apple.com/kb/TS1468
Thanks for using Apple Support Communities.
Regards,
-Norm G. -
How can i get xml data from html
Hi
i need to submit data from an html form to server via xml.
( ie data shold be in xml format instead of POST/GET methods )
how can i can i make this happen ?
Renjith.read the excellent suggestion from mochamaniac (reply 2 of 5): http://forum.java.sun.com/thread.jsp?forum=34&thread=303120
ps. next time run a search on the forum prior from posting ;-) -
How can I get an extension from a file...in JFileChooser
I have got a problem here. Here I have a JFileChooser, I want to add in
a FileFilter, and user could only see some type of file. But as long as I
try to get the extension....It wont compile, could any one teach me how
to get the extension of a file in JFILECHOOSER???
============================================
import java.io.*;
import java.io.File.*;
import javax.swing.filechooser.FileFilter;
public class MainFrame extends JFrame implements ActionListener {
public MainFrame() {.............}
private boolean chooseFile()
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
FileChoser filtering = new FileChoser("txt");
fileChooser.setFileFilter(filtering);
fileChooser.addChoosableFileFilter(filtering);
int selection = fileChooser.showOpenDialog( this );
if ( selection == JFileChooser.CANCEL_OPTION )
return false;
if (selection == -1) {
return false;
File tmpfile = fileChooser.getSelectedFile();
filename = tmpfile.toString();
setTitle( "Smiggin Holes 2010 - " + filename );
return true;
static class FileChoser extends javax.swing.filechooser.FileFilter
String extension;
String description;
public FileChoser(String extension, String description){
this.extension = extension;
this.extension = description;
// Accept all directories and all gif, jpg, or tiff files.
public boolean accept(File f)
if (f != null)
if (f.isDirectory())
return true;
String ext = getExtension(f); //<<<<<<<<<<<THE PROBLEM IS HERE WHEN I TRY TO GET THE EXTENSION OF THE FILE. IT CANT COMPILE
System.out.println("aasdfasdf"+ext);
if ((ext!=null)&&(ext.equals(extension)))
return true;
return false;
// The description of this filter
public String getDescription() {
return "Just Text Files";
======================================
Could you tell me what can I do? To get the extension of the file selected by the user?
And What do I have to change?
Regards,Hi,
can you post your compile error and the code of getExtension().
Regards
Ldinka -
How can i get all elements from a arraylist
Hello everyone
I have an arraylist with 40 elemets inside it.
I want to be able to get the first 10 elements of the arraylist and put them into a sql statement (I can do this ok) but the problem is when i want to get the next 10 elements (from 10 to 20) they will not execute to the database. is this possible with just one prepared statement?
thanks
piperHello Ken this is my code so far, And i keep getting the error
binary data would be truncated.
And if i change the values in the for loop i get an exception null.
I do not know what is wrong with this so could you be so kind as to. help me thaks
piper
try {
String data = "jdbc:odbc:myProject";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(data,"","");
int rows=0;
PreparedStatement ps = conn.prepareStatement(
"INSERT INTO Ben (Phone,addr1,addr2,PostCode) VALUES (?,?,?,?)");
Iterator io = arr3.iterator();
while (io.hasNext())
for (int pos = 1; pos <=4; pos++)
String sf = (String)io.next();
ps.setString(pos,sf);
rows += ps.executeUpdate();
System.out.println("inserted" + rows + " rows");
ps.close();
return;
}catch (Exception e1) {
System.err.println("Got an exception! ");
System.err.println(e1.getMessage()); -
Question
Printing internet pages
Reduced print size
Only the first page is reduced and printed as desired
All pages after the first page are full size with information cut off
Recent problem never seen before
Can print from Safari and other software just fine
How can I get all pages to be reduced size?One suggestion worked from the Firefox prints incorrectly link mentioned above by mha007. I'm thrilled since this has been annoying me for weeks. Thanks mha007!
Reset all Firefox printer settings
# Open your profile folder:
# On the menu bar, click on the Help menu and select Troubleshooting Information. The Troubleshooting Information tab will open.
# Under the Application Basics section, click on Show in Finder. A window with your profile folder will open.
# Note: If you are unable to open or use Firefox, follow the instructions in Finding your profile without opening Firefox.
# On the menu bar, click on the Firefox menu and select Quit Firefox.
# In your profile folder, copy the prefs.js file to another folder to make a backup of it.
# Open the original prefs.js file in a text editor (such as TextEdit).
# Remove all lines in prefs.js that start with print. and save the file.
# If something goes wrong when you open Firefox, close it again and overwrite prefs.js with the backup you made. -
How can i get the data from database & add them as a link
Hi,
how can i get a data from a database(DB2) and that data will be having a file so i should make them as a link.i tried it in jsp .
<%
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
response.setContentType("text/html");
Connection conn = null;
conn = DriverManager.getConnection("jdbc:db2:spintran");
Statement stmt = conn.createStatement();
stmt.executeQuery("set current schema tut");
ResultSet rs = stmt.executeQuery("select * from tutorial");
%>
Type Of the Category :    
<%
while (rs.next())
String desc = rs.getString(1);
out.println(desc);
%>
<A HREF = "<%=desc%>"><%=desc%> </A>
<%
%>
but it is not working.how can i link.
thank you.what is desc? is it the file name ? whats the data type of desc in db? INFILE?
if desc is just the name of the file, then make sure that such a file exists in the proper folder.only then the link works..
that is, if desc is 'a.jpg' then a.jpg should be existing in the same folder as your html is. -
Like I said, my back up broke and I can't get all of my music back by transfering purchases because I burned a lot of CD's I had collected from the past. I don't have any of those CD's anymore, so how can I get all of my music onto my new iTunes? Or am I just S.O.L.?
Phone to Mac,this app lets you easily copy, transfer the music, videos and playlists from any iPod or iPhone directly into iTunes on any Mac.
-
I had to get my hard drive replaced from Apple, I lost all of my music obviously. My question is, how can I get all my music off of my iPhone onto iTunes? Since it's a new hard drive, the iPhone isn't recognizing this as it's home computer.
You will need to use third-party software to transfer music from your phone to the iTunes Library. I recommend Phone to Mac - Pod to Mac | Macroplant.com.
-
When creating a book in iphoto, how can I get all the photos from the album I want to use to show up in the order that they are in the album? When I tried to use the option to add my own photos instead of having the program "flow" them, they showed up all mixed up.
iPhoto puts them in the book in chronological order. So to get your photos from an album into an iPhoto book in the same order you will need to use the Photos ➙ Batch Change ➙ Date menu option and set them all to the same date with a 1 minute time difference between each.
OT -
I have an ancient laptop (from 2005) that has my entire music library. This laptop barely works and some keys don't type anymore. How can I get all this music transferred to another computer, or available to me on the cloud?
No... do not move programs.
About the iTunes library files
Your iTunes library files track the media you add to iTunes, how you've organized it, and other information such as playlists. By default, these two files are in your iTunes folder:
Mac OS X: /Users/username/Music/iTunes/
Windows XP: C:\Documents and Settings\username\My Documents\My Music\iTunes\
Windows Vista: C:\Users\username\Music\iTunes\
Windows 7: C:\Users\username\My Music\iTunes\
Windows 8: C:\Users\username\My Music\iTunes\ -
All the CD's I have imported will not play. The only music that will play is cd's I have purchased from itunes. How can I get all my albums to play, please??
iTunes Store- Transferring purchases from iOS device or iPod to a computer
Downloading past purchases from the App Store, iBookstore, and iTunes Store
How to dowload purchased music
Maybe you are looking for
-
Problem reading content link from repository
Hi I stored some html link & images in the content repository.I am able to show them in my jsp page(one by one).After that if i click the any of the displayed links, i am getting following error messages.Can u help me this one ? Here i enclosed code
-
HT4993 how to factory unlock Iphone 5 Sprint
How to factory unlock iphone 5 Sprint carrier
-
HT4993 my phone wont connect to itunes so i can restore it
My phone won't connect
-
11gR2 OCR and ASM, recommendation please
For 11gR2 - storing OCR on ASM I see posts recommending that OCR be stored in a seperate diskgroup from Database or recovery files, but no detail on why. I'm mearly seeking to understand the recommendation, I'm not questioning it. Please can someone
-
When I go to goole.ca I get redirected.
When I go to Firefox and then click on google.ca I am directed to my internet providers web site. I contacted the provider and they told me that it was a Firefox problem as they are my browser. This happened just after I set up a new cisco dpc 3825