file_get_html() not working for the only webpage - simple-html-dom

I want to call a simple DOM file
I tested with another links and it works, but with this url it's not working.
My code is:
$bnadatos = file_get_html("http://www.rofex.com.ar/cem/FyO.aspx");
foreach($bnadatos->find('[#id="ctl00_ContentPlaceHolder1_gvFyO"]') as $i){
echo "datos:";
echo $i->innertext;
}
Response is a blank page.
What's wrong?

i solved with
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$response = file_get_html("https://www.rofex.com.ar/cem/FyO.aspx", false, stream_context_create($arrContextOptions));
foreach($response->find('[#id="ctl00_gvwDDF"]/tbody/tr[2]/td[2]') as $i){
echo $i->innertext;
}
thank you #maio290 for light my road

This is just a guess, but do you have your error reporting on?
Out of the box, this is not working with the simple-html-dom library:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /var/www/html/dom.php on line 83
Warning: file_get_contents(): Failed to enable crypto in /var/www/html/dom.php on line 83
Warning: file_get_contents(http://www.rofex.com.ar/cem/FyO.aspx): failed to open stream: operation failed in /var/www/html/dom.php on line 83
Fatal error: Call to a member function find() on boolean in /var/www/html/test.php on line 11
A fix for this can be found here - with that in place, I still get a blank page, which is due to a wrong answer (301 Moved Permanently) - for this to fix, you need to modify
'follow_location' => false
to
'follow_location' => true
so, now we get the proper site content - you can modify the selector to $html->find('#ctl00_ContentPlaceHolder1_gvFyO'); this will find all element which id=ctl00_ContentPlaceHolder1_gvFyO - see the documentation as reference.

Related

Getting Curl "Unsupported protocol" error

So i am trying to build a project with gcc and it emits the following compile failure
/home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp:247:26: error: ‘CURLOPT_HTTPPOST’ is deprecated: since 7.56.0. Use CURLOPT_MIMEPOST [-Werror=deprecated-declarations]
247 | ret = setopt(CURLOPT_HTTPPOST, m_post);
| ^~~~~~~~~~~~~~~~
In file included from /home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/include/AVSCommon/Utils/LibcurlUtils/CurlEasyHandleWrapper.h:20,
from /home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp:20:
/usr/include/curl/curl.h:1195:3: note: declared here
1195 | CURLOPTDEPRECATED(CURLOPT_HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24,
| ^~~~~~~~~~~~~~~~~
/home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp: In member function ‘void alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::cleanupResources()’:
/home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp:302:22: error: ‘void curl_formfree(curl_httppost*)’ is deprecated: since 7.56.0. Use curl_mime_free() [-Werror=deprecated-declarations]
302 | curl_formfree(m_post);
| ~~~~~~~~~~~~~^~~~~~~~
/usr/include/curl/curl.h:2606:1: note: declared here
2606 | curl_formfree(struct curl_httppost *form);
| ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[3]: *** [AVSCommon/CMakeFiles/AVSCommon.dir/build.make:734: AVSCommon/CMakeFiles/AVSCommon.dir/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:11124: AVSCommon/CMakeFiles/AVSCommon.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:18943: SampleApplications/ConsoleSampleApplication/src/CMakeFiles/SampleApp.dir/rule] Error 2
make: *** [Makefile:5093: SampleApp] Error 2
basically the project is using deprecated API's . While trying to upgrade it to use the new API i am encountering a weird behaviour where the execution of that line fails and the curl error message that i am receiving is Unsupported protocol
auto result = curl_easy_setopt(handle, option, value);
Please note that value of option and value are CURLOPT_HTTP_VERSION and CURL_HTTP_VERSION_2_0
but if i add the following curl code above the above mentioned code snippet as shown below than everything starts to work magically
FILE *filep = fopen("~/dump.txt", "wb");
if(handle) {
curl_easy_setopt(handle, CURLOPT_STDERR, filep);
}
auto result = curl_easy_setopt(handle, option, value);
it seems like curl_easy_setopt(handle, CURLOPT_STDERR, filep);
must happen before curl_easy_setopt(handle, option, value)otherwise i get the unsupported protocol error. Can someone more experienced than me knows why that is happening or what i might be missing here.
Please note that initially i thought that the program is succeeding maybe due to some timing issue therefore i also tried putting some delay above auto result = curl_easy_setopt(handle, option, value); but still saw the same error message.

PDFPageCountError: Unable to get page count

I am trying to use pdf2image, but I am getting this error:
PDFPageCountError: Unable to get page count.
I/O Error: Couldn't open file 'C:\Users\user_name\Desktop\folder_name\folder2_name\folder3_name\007-084841-1 to 31 Dec'22': No error.
It is confusing as it doesn't give any error, it just says 'No error'
My code is:
doc = convert_from_path("C:\\Users\\user_name\\Desktop\\folder_name\\folder2_name\\folder3_name\\007-084841-1 to 31 Dec'22")
path, fileName = os.path.split("C:\\Users\\user_name\\Desktop\\folder_name\\folder2_name\\folder3_name\\007-084841-1 to 31 Dec'22")
fileBaseName, fileExtension = os.path.splitext(fileName)
for page_number, page_data in enumerate(doc):
txt = pytesseract.image_to_string(Image.fromarray(page_data)).encode("utf-8")
print("Page # {} - {}".format(str(page_number),txt))
Can anyone help me please?
I don't know what to try as the error message just says Unable to open...: No error

Fatal error within Woocommerce "wc-template-functions.php" file

I have tried to edit wc-template-functions.php in my store and did something wrong.
Now I am getting Fatal Error on 281 line.
Fatal error: Uncaught Error: Class 'Constants' not found in /home/kidsandm/oliverthedog/wp-content/plugins/woocommerce/includes/wc-template-functions.php:282 Stack trace: #0 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(292): wc_generator_tag('<meta name="gen...', 'xhtml') #1 /home/kidsandm/oliverthedog/wp-includes/plugin.php(212): WP_Hook->apply_filters('<meta name="gen...', Array) #2 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4728): apply_filters('get_the_generat...', '<meta name="gen...', 'xhtml') #3 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4650): get_the_generator('xhtml') #4 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4627): the_generator('xhtml') #5 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(292): wp_generator('') #6 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) #7 /home/kidsandm/oliverthedog/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #8 /home/kidsandm/oliverthedog/wp-includes/gen in /home/kidsandm/oliverthedog/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Before that I also had warning at the top that said:
Warning: The use statement with non-compound name 'AutomatticJetpackConstants' has no effect in /home/kidsandm/hondamarine/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 11
but I have hide that line thinking it might help.
What I have change in file?
Additional information.
I was thinking it will change the name of it on front-end as well.
// Additional information tab - shows attributes.
if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
$tabs['additional_information'] = array(
'title' => __( 'Additional information', 'woocommerce' ),
'priority' => 20,
'callback' => 'woocommerce_product_additional_information_tab',
);
}
Line 1798.
I have tried to find a code only to replace it, and I found one but did not help.
Now, that code might not be original because I could not find it on GitHub.
Thanks a lot!
It just happened to me too, I tried to edit the code for the same reason, I searched a lot about this problem and I solved it when I downloaded the plugin in zip form and manually upload it and install it, now its working fine for me and all data still in place (categories, products, etc.)!
I had the following 2 errors:
Fatal Error: Uncaught error: Class 'Constants' not found in /Users/anastasiades/Local Sites/pisinaspa/app/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Error: Class 'Constants' not found in /Users/anastasiades/Local Sites/pisinaspa/app/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Steps:
1. Backup data in woocommerce
2. Download plugin here
3. On WordPress go to Plugins >> Add new >> Upload plugin
4. Choose Reinstall >> Install now
5. "Replace current with uploaded"
I recommend a good backup of the products and other data before doing this.
Peace!

Error parsing afsocket, inner-dest plugin disk-buffer not found...?

I'm modifying syslog-ng.conf with the following changes.
destination d_tls{
syslog("IP"
port(514)
transport("tls")
tls(
ca-dir(CertPath)
cert_file(NodeCredentialCert)
key_file(NodeCredentialKey)
peer_verify(requared-trusted)
)
disk-buffer(
mem-buf-size(524288)
disk-buf-size(1048576)
reliable(yes)
dir(SYSLOG_BUFFER_DIR)
)
);
};
Now I'm getting following error.
Error parsing afsocket, inner-dest plugin disk-buffer not found in /etc/syslog-ng.conf at line 350, column 3:
disk-buffer(
^^^^^^^^^^^
Can anyone tell me the issue here? What should I change?
I'm using following syslog-ng version.
syslog-ng 3.3.6
Installer-Version: 3.3.6
Revision: ssh+git://algernon#git.balabit//var/scm/git/syslog-ng/syslog-ng-ose--mainline-
-3.3#master#d32b5c63e09a4c3897cbc2239c07967cea393de9
Compile-Date: Apr 9 2020 09:58:41
Default-Modules: affile,afprog,afsocket,afuser,basicfuncs,csvparser,dbparser,syslogformat
Error opening plugin module; module='afsocket-notls', error='/usr/lib64/syslog-
ng/libafsocket-
notls.so: undefined symbol: tls_context_setup_session'
Available-Modules:
affile,afprog,convertfuncs,tfjson,dummy,syslogformat,csvparser,dbparser,afsocket-
tls,afuser,confgen,afmongodb,afsocket,basicfuncs
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: off
Enable-TCP-Wrapper: on
Enable-Linux-Caps: off
Enable-Pcre: off
The disk-buffer() module is not available in such an old syslog-ng version.
Please upgrade to at least v3.8.1. The current version (v3.28.1) contains quite a few bug fixes.

include function and Graphs in PHP

i am using libCharts in my PHP application ....the graphs are working but when i include it in the application using INCLUDE function then it does not work
it give me the error
Warning: include(charts/charts-example-line.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\MyProject\index.php on line 349
Warning: include() [function.include]: Failed opening 'charts/charts-example-line.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\MyProject\index.php on line 349
My Graph code is
$chart = new PieChart(500, 250);
$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Mozilla Firefox (80)", 1000));
$dataSet->addPoint(new Point("Konqueror (75)", 75));
$dataSet->addPoint(new Point("Other (50)", 50));
$chart->setDataSet($dataSet);
$chart->setTitle("User agents for www.example.com");
$chart->render("libchart/demo/generated/demo1.png");
?>
<html>
<body>
<img src="libchart/demo/generated/demo789.png" border=0 />
</body>
</html>
please help me
There's nothing wrong with your graph code. Rather, the libCharts files are not able to be found by PHP, because the directory they are in is not in the "include_path" lists of paths that PHP will search.
You might want to read these PHP manual pages:
http://php.net/manual/en/ini.core.php#ini.include-path
http://php.net/manual/en/function.set-include-path.php
http://php.net/manual/en/function.include.php

Resources