Extract image path from HTML in Objective C [duplicate] - objective-c

This question already has an answer here:
Objective c getting image from an html string
(1 answer)
Closed 10 years ago.
Help!!!
I am fairly new to iPhone App development and I am caught up with parsing!
I am trying to read the feeds from a URL which ends in .cms
I was able to get the text from the source and remove the HTML using the flattenHTML code but I am having trouble with extracting the path for the image.
The path for the image is in something like: ....(text+html)...><img src="http://www....
If anybody could please help and suggest how i can get the path for the image extracted... :((
Thanks in advance!

You may apply a regular expression on your text to extract the path.
The pattern would be something like <img.*src?=?"(.*?)"

Related

Karate- Getting current date and manipulating it is not returning anything [duplicate]

This question already has an answer here:
Karate: Validate a specific date in JSON response
(1 answer)
Closed 1 year ago.
I apologize in advance if this seems like it's in the wrong place. However, what I have seems to work in pure JavaScript. However, when added in my Karate script, it's returning an empty object.
I have the following script:
* def currentDateMinusOne = new Date(new Date().setFullYear(new Date().getFullYear() - 1))
* karate.log("current date minus one year:", currentDateMinusOne)
The Karate log spits out an empty {}. Any ideas on what could be going on?
I don't know if the JavaScript Date behaves properly using the Karate JS engine, and I personally have never used it. You are welcome to experiment and report your findings.
My recommendation is to use Java interop. This example should get you going: https://stackoverflow.com/a/60945563/143475

Create a notebook from several md files [duplicate]

This question already has answers here:
Markdown and including multiple files
(20 answers)
Closed 2 years ago.
I'm new to Stack Overflow.
I write a lot. So I created different .md files in different directories.
Now I wanna create a notebook(it doesn't matter in .pdf format or another .md) from all the md files but I have some problems:
It will be messy I guess
I don't know how to do so
I wanted to know if there is a way to do it in a tidy way :)
I see your post is tagged for r-markdown, so I am going to show you how to do it the r-markdown way.
You can create an index.Rmd file (this doesn't have to be named index.rmd) that links to other r markdowns.
In your index file, add a code chunk with the following bit of code:
```{r child = 'children/summary.Rmd'}
```
This will knit what you have in the summary.Rmd into index.Rmd. For this example, I put summary.Rmd into a sub directory called "children".
Let me know if you have any questions!
I believe that the fastest and the most hassle-free way for you to start with the notebook is to use one of the myriads of static generators available (for example, MkDocs Material) or proceed with an application for taking notes (for example, Notable, Boost Note, and Joplin)

Karate Automation: Is there any way we can set the Scenario name dynamically from a json file [duplicate]

This question already has answers here:
Can we parameterize the request file name to the Read method in Karate?
(2 answers)
Closed 1 year ago.
I am using a JSON file which act as a test case document for my API testing. The JSON contain Test Case ID, Test case Description, Header and Request body details, which should be the driving factor of Automation
Currently i am looping a feature over this json file to set different header and body validations. However it will be helpful if i can set the Scenario name from JSON file while its iterating
Something like
serverpost.feature
Feature:re-usable feature to publish data
Scenario: TC_NAME # TC_NAME is avaliable in the JSON data passed to this feature. However, CURRENTLY ITS NOT TAKING THIS DATA FROM JSON FILE.
Given path TC_ID # TC ID is taken from JSON
Given url 'http://myappurl.com:8080/mytestapp/Servers/Data/uploadServer/'
And request { some: '#(BODY)' } # Request Body Details is taken from JSON
Please suggest
In my honest opinion, you are asking for a very un-necessary feature. Please refer to the demo examples, look for it in the documentation.
Specifically, look at this one: dynamic-params.feature. There are multiple ways to create / use a data table. Instead of trying to maintain 2 files - think of Karate as being both - your data table AND the test execution. There is no need to complicate things further.
If you really really want to re-use some JSON lying around, it is up to you but you won't be able to update the scenario name, sorry. What I suggest is just use the print statement to dump the name to the log and it will appear in the HTML report (refer to the doc). Note that when calling a feature in a loop using a JSON array, the call argument is ALREADY included the report, so you may not need to do anything.
Just an observation - your questions seem to be very basic, do you mind reading the doc and the examples a bit more thoroughly, thanks.

How can I get the Infobox from a Wikipedia article by the MediaWiki API? [duplicate]

This question already has answers here:
How to get the Infobox data from Wikipedia?
(8 answers)
Closed 3 years ago.
Wikipedia articles may have Infobox templates. By the following call I can get the first section of an article which includes an Infobox.
http://en.wikipedia.org/w/api.php?action=parse&pageid=568801&section=0&prop=wikitext
I want a query which will return only Infobox data. Is this possible?
You can do it with a URL call to the Wikipedia API like this:
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xmlfm&titles=Scary%20Monsters%20and%20Nice%20Sprites&rvsection=0
Replace the titles= section with your page title, and format=xmlfm to format=json if you want the article in JSON format.
Instead of parsing infoboxes yourself, which is quite complicated, take a look at DBPedia, which has Wikipedia infoboxes extracted out as database objects.
Building on garry's answer, you can have Wikipedia parse the info box into HTML for you via the rvparse parameter like so:
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Scary%20Monsters%20and%20Nice%20Sprites&rvsection=0&rvparse
Note that neither method will return just the info box. But from the HTML content, you can extract (via, e.g., Beautiful Soup) the table with class infobox.
In Python, you do something like the following
resp = requests.get(url).json()
page_one = next(iter(resp['query']['pages'].values()))
revisions = page_one.get('revisions', [])
html = next(iter(revisions[0].values()))
# Now parse the HTML
If the page has a right side infobox, then use this URL to obtain it in txt form.
My example is using the element hydrogen. All you need to do is replace "Hydrogen" with your title.
https://en.wikipedia.org/w/index.php?action=raw&title=Template:Infobox%20hydrogen
If you are looking for JSON format use this URL, but it's not pretty.
https://en.wikipedia.org/w/api.php?action=parse&page=Template:Infobox%20hydrogen&format=json

What does visibleContentsAsDataURL exactly do?

I am currently trying to build my first Safari extension. The SafariBrowserTab Class has a Method called "visibleContentsAsDataURL".
I don't exactly understand what it does and can't get it to work.
The docs just say: "Returns a data URL for an image of the visible contents of the tab."
What does it mean? That I get the URL of a screenshot of the tabs' content back? Can someone explain me?
Thanks!
I think it returns what is effectively a screenshot of the tab. The format is explained here
http://en.wikipedia.org/wiki/Data_URI_scheme
According to Apple's Safari reference documentation the return value is "a base-64 encoded PNG."
A data URL is a specal type of url basically consisting of a mimetype and data, in the case of png you'll get something along the lines of:
data:image/png;base64;lotsofstuff
You can then do whatever you want with it (it's just a string), or if you want to display the content:
img = new Image();
img.src = someTab.visibleContentsAsDataURL();
someElement.appendChild(img);
or
someCanvasContext.drawImage(img);
etc