Clean module opening.
This commit is contained in:
		
							parent
							
								
									ff69981a5c
								
							
						
					
					
						commit
						35cf4a46a8
					
				
					 2 changed files with 14 additions and 36 deletions
				
			
		|  | @ -1,32 +1,14 @@ | ||||||
| open Str | open Str | ||||||
| open String |  | ||||||
| open Printf |  | ||||||
| 
 |  | ||||||
| (*open SimpleHttp*) |  | ||||||
| 
 |  | ||||||
| open Ssl |  | ||||||
| open Http_client.Convenience |  | ||||||
| open Https_client |  | ||||||
| open Nethtml |  | ||||||
| open Netchannels;; |  | ||||||
| 
 |  | ||||||
| Ssl.init(); |  | ||||||
| Http_client.Convenience.configure_pipeline |  | ||||||
| (fun p -> |  | ||||||
|   let ctx = Ssl.create_context Ssl.TLSv1 Ssl.Client_context in |  | ||||||
|   let tct = Https_client.https_transport_channel_type ctx in |  | ||||||
|   p # configure_transport Http_client.https_cb_id tct |  | ||||||
| ) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| let is_url url = | let is_url url = | ||||||
|   let regexp = Str.regexp "\\(https?\\://\\)?www\\..+\\..+" in |   let regexp = regexp "\\(https?\\://\\)?www\\..+\\..+" in | ||||||
|   Str.string_match regexp url 0 |   string_match regexp url 0 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| let is_youtube_url url = | let is_youtube_url url = | ||||||
|   let regexp = Str.regexp "\\(https?\\://\\)?\\(www\\.\\)?\\(youtube\\.com\\)\\|\\(youtu\\.be\\)/.+" in |   let regexp = regexp "\\(https?\\://\\)?\\(www\\.\\)?\\(youtube\\.com\\)\\|\\(youtu\\.be\\)/.+" in | ||||||
|   Str.string_match regexp url 0 |   string_match regexp url 0 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| (* Maybe have a list of functions and | (* Maybe have a list of functions and | ||||||
|  |  | ||||||
|  | @ -1,31 +1,27 @@ | ||||||
| open Str |  | ||||||
| open String |  | ||||||
| open Printf | open Printf | ||||||
| open Ssl | open Http_client | ||||||
| open Http_client.Convenience |  | ||||||
| open Https_client | open Https_client | ||||||
| open Nethtml | open Nethtml;; | ||||||
| open Netchannels;; |  | ||||||
| 
 | 
 | ||||||
| Ssl.init(); | Ssl.init(); | ||||||
| Http_client.Convenience.configure_pipeline | Convenience.configure_pipeline | ||||||
| (fun p -> | (fun p -> | ||||||
|   let ctx = Ssl.create_context Ssl.TLSv1 Ssl.Client_context in |   let ctx = Ssl.create_context Ssl.TLSv1 Ssl.Client_context in | ||||||
|   let tct = Https_client.https_transport_channel_type ctx in |   let tct = https_transport_channel_type ctx in | ||||||
|   p # configure_transport Http_client.https_cb_id tct |   p # configure_transport https_cb_id tct | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| let extract_string_value document = | let extract_string_value document = | ||||||
|   match document with |   match document with | ||||||
|   | Nethtml.Data(s) -> s |   | Data(s) -> s | ||||||
|   | _ -> "" |   | _ -> "" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| let rec get_title_element document = | let rec get_title_element document = | ||||||
|   match document with |   match document with | ||||||
|   | Nethtml.Element(e, args, sub) -> Printf.printf "%s: %s" "Element\n" e |   | Element(e, args, sub) -> printf "%s: %s" "Element\n" e | ||||||
|   | Nethtml.Data(s) -> Printf.printf "%s: %s" "Data\n" s |   | Data(s) -> printf "%s: %s" "Data\n" s | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| let get_http_title body = | let get_http_title body = | ||||||
|  | @ -36,6 +32,6 @@ let get_http_title body = | ||||||
| 
 | 
 | ||||||
| (* TODO: Log errors *) | (* TODO: Log errors *) | ||||||
| let get_body url = | let get_body url = | ||||||
|   try Http_client.Convenience.http_get url with |   try Convenience.http_get url with | ||||||
|   | Http_client.Http_error e -> "http error /o\\" |   | Http_error e -> "http error /o\\" | ||||||
|   | Failure f -> "http fail lol" |   | Failure f -> "http fail lol" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue