Jump to content

how to get the language and list pages from site


new_member
Go to solution Solved by .josh,

Recommended Posts

Hi,

 

I want to get the language defined in html or meta tags using php as <html lang="en"> using php. I have searched a lot in google but cannot find any way. Similarly i also want to get the language in site being used as if the site text is in japanese there shoould be any function to return the japense language using php. Is there any way to do this?? urgent help needed. Thanks

Link to comment
Share on other sites

I pointed you in the right direction. There are a shitton of tuts out there for scraping pages in general or using DOM. I'm not going to regurgitate that here. If you have some specific issue we'll be happy to help or point you in the right direction, but as it stands now, this sounds like a thinly veiled "write my script for me" request - something we don't do.

Link to comment
Share on other sites

Have a look at the example code @ http://www.phpro.org/examples/Parse-HTML-With-PHP-And-DOM.html

 

Play around with that. Read the documentation for using DOM ( .josh probided a link earlier). You should be able to get lang attribute for the html tag in just a few lines of code. All it takes is for you sit down read documentation testing/playing with examples and then you should be able to implement this yourself.

Link to comment
Share on other sites

I have used

 

$dom = new DOMDocument();
$dom->loadHTML($file);
$node = $dom->getElementById("registryData");
$output = $dom->saveHTML($node);

echo $output;

 

 

However i have used many other codes like this to parse the data within the html tages like anchor tags, img etc but i cannot find any way to find the language used.

Link to comment
Share on other sites

  • Solution

Think about what you are trying to get. Read what getElementById does. Do you think it is going to give you the page language? page language will either be in the html tag or a meta tag, neither of which has an id attribute. You will need to use getElementsByTagName and then loop through them checking for appropriate attributes using getAttribute

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.