Retrieving search results from Google using YAML

Note: I am completely new to YAML and have not yet grasped the concepts behind it. Therefore, my question might include some irrelevant content related to YAML. Please excuse me and feel free to correct any mistakes.

While using a music player (MusicBee), I came across a plugin that retrieves song lyrics. The process of fetching lyrics from a provider is described in a YAML file (yml). For instance, the lyrics from AZLyrics are fetched using the following yml file;

name: A-Z Lyrics Universe
url: "http://www.azlyrics.com/lyrics/{artist}/{title}.html"
extractor: '(?s)<div>\s+<!--\s+Usage.*?\s+-->(?P<lyrics>.+?)</div>'

headers:
- name: User-Agent
  value: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0' # Firefox 30 Win x64 user agent

variables:
- &artist
  name: artist
  filters:
    - [lowercase]
    - [strip_nonascii]
- <<: *artist
  name: title

filters:
- [strip_html]
- [trim]
- [utf8_encode]

The direct URL for the lyrics is provided as;

http://www.azlyrics.com/lyrics/{artist}/{title}.html

However, the problem arises for me here. Instead of using the above link, I need to conduct a simple google search like this;

https://www.google.lk/search?q={artist}+{title}+azlyrics+lyrics

I want to extract the first URL from the search results and use it as the lyric URL.

Questions:

  1. Is YAML capable of handling the task I require?
  2. If yes, how can I achieve this? How do I handle Google search results?
  3. If not, could you provide any suggestions on what steps I should take to accomplish my goal?

Note: Here's the source code of the mentioned plugin.

Answer №1

Sorry, it's not possible to accomplish that using YAML since it is primarily a human-readable data serialization language.

YAML serves as a way to organize and store data in a readable format.

You will need to utilize a programming language that supports making HTTP requests in order to achieve the desired outcome, with many popular languages offering this functionality.

Without knowing your preferred programming language, I can only provide general steps for you to follow:

  1. Send an HTTP request to the designated Google URL
  2. Parse the received data
  3. Extract the first link from the results
  4. Utilize this link in your project as needed

The specific implementation of these tasks will vary based on the programming language you choose, but the overall process remains similar.

Update:

If working in Java, Google offers an API that allows for programmatically querying search results. Check out this example for more information.

Answer №2

YAML/YML provides an alternative to .properties/.json files with its user-friendly approach.

"YML" files are commonly used for setting configuration/meta data in applications.

This format serves as a means of representing data, requiring your code to interpret and act upon it - such as searching Google for results in this scenario.

Just like there are libraries for handling .json files in specific languages, similar libraries exist for .yml files as well.

Explore more about YAML at .

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

SQL JSON condition clause

I am currently working with a table that contains a column named PRICING_DATA, which is of type JSON. Here is an example: pricingJson type json nullable I have written an SQL query to retrieve data from this table based on the value of a specific key in ...

Creating a nested JSON response with an Array in a Stored Procedure

I have extracted a dataset from a stored procedure result +------+--------+---------------------+------------+ | Line |Status | Consent | tid | +------+--------+---------------------+------------+ | 1001 | 1 | Yes | ...

Extract the year from a string formatted as 1880-01-01T00:00:00.000

Looking to extract the year from an array of dates with format 1880-01-01T00:00:00.000. What's the most efficient method to accomplish this using JavaScript? ...

Is it possible to utilize enums as keys in a Json structure?

I am currently utilizing TypeScript in conjunction with Node.js (MEAN stack). My aim is to incorporate an enum within the property/schema of a JSON object. An example of the enum would be: enum KeyEnums { A: "featureA", B: "featureB&qu ...

Get a collection of strings from a WCF service triggered by jQuery

After calling my service to retrieve a list of strings, I encountered an error message. $(document).ready(function () //executes this code when page loading is done { $.ajax({ type: "POST", url: "Services/pilltrakr.svc/getAllUsers", ...

What is the method to create all possible combinations from the keys of a JSON object?

How can I generate object B that includes all combinations of object A using a key-value pair? { "x": "data-x", "y": "data-y", "z": "data-z" } The desired output should look like this: { ...

Query regarding conversion of JSON objects

I am having an issue with converting JSON to object and then from object to array. The result is not what I expected. Can someone help me understand why? $json = '{"0" : "a"}'; $obj = json_decode($json); $a = (array) $obj; print_r($a); echo("a0: ...

Error: Found an unconventional token "e" in JSON data at position 1 during parsing in JSON.parse function

Is there a way to retrieve a string value by calling an API in Angular? Here is my approach: Service file - public getRespondDashboardUrl(): Observable<any> { return this.http.get(`ref/RespondDashboardUrl`); } Component File respondDashboar ...

Is it possible to utilize a JavaScript variable in this particular scenario and if so, what is the

let myVariable = <?php echo json_encode($a[i want to insert the JS variable here]); ?>; Your prompt response would be highly valued. Many thanks in advance. ...

What is the best way to handle JSON data errors when a value is undefined?

I am currently working on a piece of code that displays JSON data in HTML. However, if a value is undefined, it doesn't display anything. How can I handle this error so that if a value is undefined, it will show "N/A" instead of breaking the code? ...

Casting user-defined data types to JSON objects can be achieved using the `jason.simple` library

I'm facing an issue with type casting a user-defined data type, USERS, into a JSON Object. When I tried using .toString() to convert Users into a String, the output was unexpected and incorrect. I then considered converting it into a JSON Object and r ...

Ending the loop of a jQuery JSON array when reaching the final row

I have a function that retrieves a JSON array and shows the results as a list with ten items. However, if there are fewer than ten results, it starts over from the beginning. This is my code: $.ajax({ url: 'http://www.entertainmentcocktail.com/c ...

Combining two queries into a single JSON object

I have a couple of questions: 1) $result = $this->_db->get_where("wishes",array("is_open"=>1))->result_array(); 2) $requirements_result = $this->_db->get("requirements")->result_array(); I am attempting to format the data in JSON as ...

Issue with converting valid JSON to XML using XSLT 3.0 json-to-xml() function

The following JSON appears to be valid, but when attempting to transform it using XSLT 3.0's json-to-xml() function, an error related to the JSON syntax is encountered. { "identifier": { "use": "<div xmlns=\"http://www ...

Updating a model in Angular JS after sending a JSON GET request: A step-by-step guide

Having issues with my simple page that displays records based on the selected year. The sidebar selection is not highlighting properly. The initial data loads fine when I first visit the page. However, when I try to change the year and click "Go", the mai ...

Utilizing multiple UILocalNotifications simultaneously

Hey there, I've encountered an issue with using UILocalNotification. I'm receiving notifications from a server and storing the data in a MutableArray. Here's a snippet of what it looks like: idnoty * id of notification titlenoty * title of ...

Challenges with JavaScript fetching JSON information

Resolved: To enable AJAX functionality, I needed to upload the files to my server. Currently, I am attempting to retrieve stock information from a JSON file, but no data is being displayed. Upon alerting ajax.status, it returned 0 as the result, indicatin ...

Extract keys enclosed in quotation marks using regular expressions

My coding challenge involves working with JSON data in a specific format: define({ somekey : "Some {text} here:", 'some-key' : "Text:", 'key/key' : 'Some : text', key: 'some value', 'my-key' : &a ...

Deserialization of Newtonsoft Array with Index Key

I am utilizing the newtonsoft.Net library for Deserializing/Serializing Objects. Is it possible to Deserialize the JSON below as an Array of "OfferPixel" objects? Each object within the array is assigned an index number on the service. Therefore, the "Of ...

Which is the better choice: JSON file or SQL for storing data?

I am in the process of developing a website that will feature an ajax search functionality. This search will retrieve data either from a JSON file or from a MySQL database. I am unsure which technology would be best suited to store this data. With approxim ...