Wordpress Database search and replace html and keep content - sql

I have a problem. An old plugin created a lot of unnecessary tags in all my 700 WordPress blog posts.
Currently the html of every h2-tag looks like this:
<h2><a class="chartbeat-section" target="_blank" rel="nofollow noopener" name="name"></a>title</h2>
The outcome should be just:
<h2>title</h2>
Is it possible to get rid of the a-tag inside of every h2-tag with some sql query?
Thanks in advance.

Related

Splunk-Dashboard - how to add links as field in table visualization?

I'm sending as a - payload.url field - some link for each event,
but in the dashboard - table it's appeare as text and not as link.
maybe someone tried to do it?
i've added - Visit example website
the tage into the payload and try to sent it in two ways:
Visit example website
"https://www.example.com"
both are appeare as text and not as links.
thanks all, what I needed to do is - add this:
<drilldown>
<link target="_blank">$row.URL|n$</link>
</drilldown>
found it here - https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-make-a-clickable-hyperlink-in-search-result/m-p/438278
thanks again
Without knowing what your dashboard looks like (a [sanitized] screenshot, XML, etc), we can only guess at what you're trying to do
That said, if you're wanting to do what I think you want to do, put the following in its own panel on your Dashboard (you'll need to do this from the Edit Source option):
{top of dashboard}
<row>
<panel>
<html>
<li>link text</li>
<li>text of link</li>
</html>
</panel>
</row>
{bottom of dashboard}

Scrapy - Cleaning up text[/p] from nested links[/a] etc

I am new to python and scrape as well. Nevertheless, I spend a few days trying to scrape news articles from its archive - SUCCESSFULLY.
PROBLEM is that when I scrape CONTENT of the article <p> that content is filled with additional tags like - strong, a etc. And as such scrapy won't pull it out and I am left with news article containing 2/3 of the text. Will try HTML below:
<p> According to <a> Japan's newspapers </a> it happened ... </p>
Now I tried googling around and looking into the forum here. There were some suggestion but from what I tried, it did not work or broke my spider:
I have read about normalized-space and remove tags but it didn't work. Thank you for any insights in advance.
Please provide your selector for more detailed help.
Given what you're describing, I'd guess you're selecting p/text() (xml) or p::text (css), which is not going to get the text in the children of <p> elements.
You should try selecting response.xpath('//p/descendant-or-self::*/text()') to get the text in the <p> and all it's children.
You could also just select the <p>, not its text, and you'll get its children as well. From there you can start cleaning up the tags. There are answered questions regarding how to do that.
You could use string.replace(,)
new_string = old_string.replace("<a>", "")
You could integrate this into a loop which iterates over a list that contains all of the substrings that you want to discard.

Need help for complicated sql update

i have a table which has many records. i am storing html data in a particular fields called Data of that table. html data in each records have many IMG tag like <img src='test.gif' />. as a sample page url here http://www.bba-reman.com/content.aspx?content=bba_reman_diagnostics_tools
go there and see that a page is showing many product images and all data comes from table. i want to use lazyload jquery plugin and for that IMG tag should look like <img src="img/grey.gif" data-original="img/example.jpg" >. so i need to update my table html data.
so i need to write a sql update statement which would iterate in all html data in all rows and find img tag inside the particular div find by ID and change src url of IMG tag like src will be fixed like src="img/grey.gif" for all images and add one attribute to all img tag like data-original="img/example.jpg"
i know my situation is bit horrible for update statement. please suggest a good way to update all IMG tag writing sql. thanks
Assuming that all your tags do actually end in />, then this would work
UPDATE myTable
SET tag = LEFT(tag, CHARINDEX('/', tag) - 1) + 'data-original=''example.gif'' />'
However, that wouldn't change the quotes, as you have done in your question, and it wouldn't remove the closing slash before the tag end, as you have done in your question.

How to get an article description or excerpt within Expression Engine

I saw in Expression Engine I can use {embed:title} and {site_name} variables, but now I need a variable to pull an excerpt or description of the article itself. Is there such a variable/tag?
ExpressionEngine tags are based solely on custom fields which you yourself have defined. So in the field group for your "articles" channel, you'll have some fields, maybe {article_summary}, {article_body}, {article_image}, etc. To display your summary, just use {article_summary} in your template.
I'm assuming that you're coming from something like WordPress maybe, where every piece of content has the_content() and the_excerpt() ... aside from a handful of global variables, and some fields which are universal to all entries (like {title}, {entry_date}, etc), ExpressionEngine isn't like that. You define what fields you use for each channel - you have complete control.
Here is the actual code you have to include in your EE template.
{exp:channel:entries channel="article" limit="5" dynamic="no"}
<div class="home_thumb">
<h1>{title}</h1>
<div class="home_thumb_img">
<img src="{article_image}">
{if article_content}
<p>{article_content}</p>
{/if}
</div>
</div>
{/exp:channel:entries}

the best method for google indexing text content in images?

I have a webpage where I put 1 image once in a while, this is just like xkcd.com
I would like to know how to let google know the text in my images.
My approach is to put the text in alt html attribute, like this:
<img
src="http://myapokalips.com/public/cartoons/021_Robot_Tattoo.png"
alt="RETARD - aw, that's a sick tattoo! - yea, bro, it means 'strength'"
/>
is that right? or should I put the text in some random metatag?
thank you in advance.
Just do it like xkcd.com is doing.