1

I am writing a program that has the user enter the url of a webpage with a video on it. The program will take that and pull down the website. The program will then pull the m3u8 link from the website and return it.

From what I have researched it seems the best way to get the webpage is using curl. My question is, once I have the webpage, how do I find that particular asset?

Chronigan
  • 83
  • 5

1 Answers1

0

A similar question has been asked before. The user who posted the question asked how to download the video and close it. The working code was posted, but subsequently deleted.

This was the working code [using libcurl/c++ etc]:

#define CURL_STATICLIB
#include <stdio.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <string>

size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
    size_t written;
    written = fwrite(ptr, size, nmemb, stream);
    return written;
}

int main(void) {
    CURL *curl;
    FILE *fp;
    CURLcode res;
    char *url = "http://localhost/aaa.txt";
    char outfilename[FILENAME_MAX] = "C:\\bbb.txt";
    curl = curl_easy_init();
    if (curl) {
        fp = fopen(outfilename,"wb");
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        fclose(fp);
    }
    return 0;
}

Also the libcurl site has other sample code on it that you may find useful.

Hope this helps

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81