i am new in iOS development i want to load a html text into textview with one hyper link my text like as
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<p>As the name suggest itself “Trueman India” will cover icons of India. Our national Magazine “Trueman India” is an expansion to our business, it is an addition to our Trueman group of Companies. Trueman group of companies was started initially with the Diamond business with the company name DTC Diamonds and Apple Diamonds in the year 1975. Later with the growth of the company, we entered into entertainment Industry under the banner, “Trueman Entertainment” in the year 2010 and “Trueman Theatres in the year 2012. Today “TRUEMAN” group of companies consists of Trueman Entertainment, Trueman Theatres and Trueman Foundation which has been our recent discovery. Now we have come with print media called “Trueman India” a National Magazine which will cover Bollywood news, Interviews of Celebrities and some part of it would be dedicated for our real heroes “Policemen” and Politicians. </p><p> If you are interested in advertising on Trueman India, click here for ad rates and details. Your input is so important to the success of this site for you and the real true man around the world. </p>
</body>
</html>
i know that UIWebView is better option but when i use it then the hyper link was open in to the same web view not in the safari.i want a link to open into safari
please give me solution.
you can catch the hyper link click action webView:shouldStartLoadWithRequest:navigationType: and return NO, then open safari for this link
Related
Hy
How i can add a default image for my site to display in the google search results when i type the name of the site to search for?
Currently every few weeks a different image/picture is displaying, current one picture from my news.
Google Search result =
https://www.may_site.com [ logo ]
Currently I added a logo to my first link at the top of the page..
<img src="/images/logo.png" width="70" height="70" alt="Sitename Logo">
Sometimes no picture is visible :/
Google reads meta tags in your page <head></head> to understand what you want to show in search results.
As far as I know there is not an official "logo" or "image" tag that Google support, but is smart enough to understand that "og:image" is the page image.
<head>
<meta name="og:image" content="http://ia.media-imdb.com/rock.jpg">
</head>
You can read more here: https://developers.google.com/search/docs/advanced/crawling/special-tags
And you can find a comprehensive list of meta here
https://gist.github.com/lancejpollard/1978404
Google supports defining your logo in structured data. Here is their documentation on it:
https://developers.google.com/search/docs/advanced/structured-data/logo
However, I think you are talking more about a general image related to a page.
Using the og:image meta tag mentioned by #supermod can be a hint. Google also understands images in certain structured data types like recipes, products, articles etc. Their gallery shows what structured data can cause rich snippets like an image:
https://developers.google.com/search/docs/advanced/structured-data/search-gallery
But it is not necessary to provide metadata or structured data to get images in the search results. Sometimes Google just picks one from the page.
I am trying to get the news article from this link. My code is :
def get_news_details(news_url):
source = requests.get(news_url)
plain_text = source.text
soup = BeautifulSoup(plain_text, "html.parser")
content = soup.findAll('div', {'class' : 'big-img-box'})
print(content[0].findAll('p'))
The result shows :
[<p></p>, <p></p>, <p></p>, <p></p>, <p></p>, <p></p>]
And the value of content is :
<div class="big-img-box">
<div class="left-imgs">
<figure>
<img alt="iOS developer hints possibility of 4K Apple TV" class="img-responsive" src="http://www.aninews.in/contentimages/detail/appletv.jpg"/>
<figcaption><span class="heading-inner-span"></span></figcaption>
</figure>
<div class="mb10"></div>
</div>
<p></p> New York [USA], August 6 <a class="highlights" href="http://aninews.in/" target="_blank">(ANI)</a>: The latest designs from Apple's HomePod firmware revealed that the tech giant is hinting the launch of a <span class="highlights"> 4K Apple TV</span> with high dynamic range (HDR) support for both <span class="highlights"> HDR10 </span> and <span class="highlights"> Dolby Vision</span>.<p></p> While the current range of Apple's TV set-top box is incompatible to 4K technology, <span class="highlights">iOS</span> developer <span class="highlights"> Guilherme Rambo</span> revealed that the company is hinting an adoption of the ultra high-definition format, reports <span class="highlights">The Verge</span>.<p></p> Reports of the new range of Apple TV have surfaced time and again over the past few months, starting February this year.<p></p> It is said that implementing the HDR and 4K content will prove to b beneficial for the company, rather than a simpler resolution, since popular online movie and television platforms like <span class="highlights"> Netflix</span> and <span class="highlights"> Amazon</span> support the two high-definition formats.<p></p> Last month, iTunes started listing movies as supporting 4K and <span class="highlights"> HDR</span> in users' purchase histories, thus providing more thrust to the speculations of the 4K <span class="highlights"> Apple</span> TV. <a class="highlights" href="http://aninews.in/" target="_blank">(ANI)</a><p></p>
</div>
I can get a somewhat clumsy version of the article by content[0].text but I cannot format it.
While inspecting the webpage in chrome, the article seems to be written inside <p>article_text</p> tags. Whereas in content, it appears as <p></p>article_text tags. If the former version is present in soup, I can get my desired output. What should be done ?
It depends what you mean by formatting. You can make it 'tidier' in fairly simple ways.
>>> import bs4
>>> import requests
>>> page = requests.get('http://www.aninews.in/newsdetail-Nw/MzI4NDIy/ios-developer-hints-possibility-of-4k-apple-tv.html').content
>>> soup = bs4.BeautifulSoup(page, 'lxml')
>>> big_img_box = soup.select('.big-img-box')
Get all the text and strip away white space.
>>> big_img_box[0].text.strip()
"New York [USA], August 6 (ANI): The latest designs from Apple's HomePod firmware revealed that the tech giant is hinting the launch of a 4K Apple TV with high dynamic range (HDR) support for both HDR10 and Dolby Vision. While the current range of Apple's TV set-top box is incompatible to 4K technology, iOS developer Guilherme Rambo revealed that the company is hinting an adoption of the ultra high-definition format, reports The Verge. Reports of the new range of Apple TV have surfaced time and again over the past few months, starting February this year. It is said that implementing the HDR and 4K content will prove to b beneficial for the company, rather than a simpler resolution, since popular online movie and television platforms like Netflix and Amazon support the two high-definition formats. Last month, iTunes started listing movies as supporting 4K and HDR in users' purchase histories, thus providing more thrust to the speculations of the 4K Apple TV. (ANI)"
Go beyond this and remove longer strings of interior white space.
>>> import re
>>> re.sub(r'\s{2,}', ' ', big_img_box[0].text.strip())
"New York [USA], August 6 (ANI): The latest designs from Apple's HomePod firmware revealed that the tech giant is hinting the launch of a 4K Apple TV with high dynamic range (HDR) support for both HDR10 and Dolby Vision. While the current range of Apple's TV set-top box is incompatible to 4K technology, iOS developer Guilherme Rambo revealed that the company is hinting an adoption of the ultra high-definition format, reports The Verge. Reports of the new range of Apple TV have surfaced time and again over the past few months, starting February this year. It is said that implementing the HDR and 4K content will prove to b beneficial for the company, rather than a simpler resolution, since popular online movie and television platforms like Netflix and Amazon support the two high-definition formats. Last month, iTunes started listing movies as supporting 4K and HDR in users' purchase histories, thus providing more thrust to the speculations of the 4K Apple TV. (ANI)"
I would like to know if there is a way to use meta information such as <meta property="og:image" content="image.jpg">and <meta name="twitter:image" content="tw-image.jpg">
to rather have image links to correctly sized images depending on what social platform they are being shared to.
In other words
A person from Facebook shares a link to my webpage http://www.example.com/pagex/ and facebook shows the image source i have provided fb-image.jpg at a size of 1200px x 900px so it does not crop my image.
Another person goes to share the same url http://www.example.com/pagex/ on google plus, and google plus chooses the source image i have provided gplus-image.jpg at a size of 1080px x 1080px so it shows my full image.
Another one for pinterest and another for twitter and another for linkedin
I hope this makes sense.
Google Image Search can also filter for re-use licences of the images. I'm wondering how they know which licence an image is published under. How can I declare that licence on my website? Is it possible to declare a licence for each image on the page, or only for the entire page including all referenced images (possibly including pre-fetched content)? And what are the licences that Google understands and can classify to their filter?
I've searched around for a while and have finally found a solution, thanks to Creative Commons. In short, for Google (and other search engines) to know what license the content on a specific page is under, you have to tell it.
This is done the same way as you give Google other data like page relationships - using the HTML structure of the page. In this case, you use the rel attribute of a tags. To declare a single-page license:
License
Of course you can change the link text to whatever, but the important bit is the rel attribute. The href should point to the license itself.
I don't know how Google knows what license it is, but that's how you declare it, and Google's robots will do the magic for you. In terms of bulk licensing, I dare say you could preprocess pages with PHP (possibly in conjunction with an SQL database) to insert this license tag.
Sources:
Creative Commons Licence Chooser;
MicroFormats' RelLicense
You can also have a look at Sitepoint's definition of the rel attribute and its uses.
Hope this helps.
In this answer, I am assuming that:
You have a collection of images licensed under, say, a Creative Commons license.
You want image search engines to return your images when the user is filtering for Creative Commons-like images.
Creating metadata HTML pages
I think the best way to attach licensing information to an image is to create a canonical HTML page corresponding to each image--much like how Wikipedia or Flickr does it.
Let's say that we want to license a gallery of images under CC BY-SA 3.0 where every image has a URL of the format https://example.com/img1.jpg.
In that case, we embed the licensing information in HTML pages with URLs that look like https://example.com/img1.jpg.html.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Viewing img1.jpg</title>
<meta property="og:image" content="https://example.com/img1.jpg" />
<link rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"/>
<link rel="canonical" href="https://example.com/img1.jpg.html"/>
</head>
<body>
<div>
<img src="https://example.com/img1.jpg" />
<small>
This image is licensed under a
<a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)</a> license
</small>
</div>
</body>
</html>
Using schema.org metadata
We can also schema.org ImageObject metadata to our metadata pages--encoding our metadata as microdata, RDFa, or JSON-LD. The schema.org markup makes it possible to add additional annotations that describe the copyright holder and how to obtain a license to use the image.
Here is an example of a JSON-LD document that you can put inside the <head> tags.
<script type="application/ld+json">
{
"#context": "https://schema.org",
"#type": "ImageObject",
"author": "Bob Smith",
"copyrightHolder": "Bob Smith's employer",
"copyrightYear": 2021,
"contentUrl": "https://example.com/img1.jpg",
"license": "https://creativecommons.org/licenses/by-sa/3.0/",
"acquireLicensePage": "https://example.com/img1.jpg.html"
}
</script>
Exposing your metadata HTML pages to search engines
Finally, you should make it easy for crawlers to find these HTML pages. You can organically pepper in links to these HTML pages whenever you embed one of your images. Alternatively, you could just list all of your HTML pages with the Sitemap Protocol.
I recently was browsing a local web design firm's portfolio and found all their sites' code begins as such:
<meta name="keywords" content="a whole bunch of keywords for their site">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
...
I was able to determine that the pages were generated by dreamweaver (at least in part).
Did dreamweaver do this, or did their "developer" just paste the code at the top of the document.
It is my impulse that this is bad practice and it might work incorrectly on some platforms but it got me wondering as to whether or not their may be a reason for this?
That is a terrible practice and invalid HTML. I bet that this would throw IE directly into quirks mode.
But as for your question, either the developer is a script kiddie and shoved the <meta> tag in there with little knowledge of the outcomes, or Dreamweaver did it. I hope it was Dreamweaver...
FYI - just had this issue and Dreamweaver does not put the meta tags in the correct position automatically. Cursor must be placed beforehand into an editable region.