shaadamin44
-
Posts
16 -
Joined
-
Last visited
Posts posted by shaadamin44
-
-
6 minutes ago, Barand said:
I was offering an alternative
I know that. But I need to do it on simple html dom.
-
6 minutes ago, ginerjm said:
If that were true, why would Barand suggest it to you?
How can I find this div[class="entry-content"] class with Barand code. I'm not sure about simplexml load function.
-
50 minutes ago, ginerjm said:
Have you not read Barand's post? I think he is suggesting to you a better way.
I can't use simple dom parser & simplexml_load_string at the same time.
-
18 hours ago, ginerjm said:
$articles = $html->find('div[class="entry-content"]') ? $html->find('div[class="entry-content"]') : []; foreach($articles as $article) { $items = $article->find('ul',0) ? $article->find('ul',0) : false; if($items !==false) { $lis = $item->find('li') ? $item->find('li') : []; foreach($lis as $b) { $mcpcons .= $b->plaintext; } } }
Not familiar with this type of exerise at all but I ask this:
Since the first line that creates $articles apparently collects multiple div blocks and you are looping thru them, do you not also need to do that for the $items collection of ul blocks? And just where is $item defined? Perhaps that needs to be in this (missing) loop?
Yeah after I collect data from $articles. I need to collect first ul blocks not others ul blocks. Then I need to get all li blocks from this ul blocks.
-
19 minutes ago, ginerjm said:
So what exactly are you able to retrieve?
I can only able to get first <ul> data. I need to make an array using <li> html datas. That's why i need to get li tags data.
-
I want to scrape a website content. here is the example html source code of that site.
<div class="entry-content"> <h2>hi tags?</h2> <ul> <li>some text</li> <li>sometext</li> <li>sometext</li> <li>sometext</li> </ul> <h2>hi tags2 ?</h2> <ul> <li>some text</li> <li>sometext</li> <li>To ometext</li> <li>Theometext</li> </ul> </div>
I want to extract data of <li> tags from first <ul> html code. Here I've tried.
include('../simple_html_dom.php'); // get DOM from URL or file //$html = check above html code $articles = $html->find('div[class="entry-content"]') ? $html->find('div[class="entry-content"]') : []; foreach($articles as $article) { $items = $article->find('ul',0) ? $article->find('ul',0) : false; if($items !==false){ $lis = $item->find('li') ? $item->find('li') : []; foreach($lis as $b){ $mcpcons .= $b->plaintext; } } }
Help me by giving the correct info how can I do that? -
There is a slider with pid value in javascript. I need to pull out pid using PHP Simple HTML DOM Parser. How to get <script> tag ?
I tried this : $html->find('div[id="thepics"]', 0)->plaintext;
I can't even pull the script tag. 2 days already I suffer, I can't pull out the javascript code & I also want the value of "pid" from the script.
Here is the code from javascript:
<div style='margin:-5px 0px 10px 0px' id=thepics> <script> var numreported = 0; messanger['tagname'] = {"C":"Close-up","B":"Barefoot","S":"Soles","A":"Arches","T":"Toenails","N":"Nylons"}; messanger['gdata'] = [{"pw":1080,"ph":1204,"gid":0,"closest":6169379,"ureported":null,"pid":6238566,"reported":"0","tags":"","similarity":270,"new":0},{"new":0,"tags":"","similarity":260,"reported":"0","pid":6238567,"ureported":null,"closest":6169395,"gid":0,"ph":1204,"pw":1080},{"pw":1080,"gid":0,"closest":6169395,"ph":1204,"ureported":null,"pid":6238568,"reported":"0","tags":"","similarity":259,"new":0},{"pw":1080,"gid":0,"closest":6169395,"ph":1350,"ureported":null,"pid":6238569,"reported":"0","tags":"","similarity":260,"new":0},{"reported":"0","similarity":267,"tags":"","new":0,"pw":1080,"gid":0,"closest":6169395,"ph":1350,"ureported":null,"pid":6238570},{"ph":1920,"gid":0,"closest":6169362,"pw":1080,"pid":6238571,"ureported":null,"reported":"0","new":0,"tags":"","similarity":260},{"reported":"0","similarity":257,"tags":"","new":0,"pw":640,"gid":0,"ph":1136,"closest":6169395,"ureported":null,"pid":6238572},{"gid":0,"closest":6169395,"ph":1136,"pw":640,"pid":6238573,"ureported":null,"reported":"0","new":0,"tags":"","similarity":256},{"ureported":null,"pid":6238574,"pw":1080,"gid":0,"closest":6169395,"ph":1346,"tags":"","similarity":248,"new":0,"reported":"0"},{"pid":6238575,"ureported":null,"gid":0,"ph":1920,"closest":6169395,"pw":1080,"new":0,"tags":"","similarity":273,"reported":"0"},{"reported":"0","new":0,"tags":"","similarity":251,"gid":0,"closest":6169395,"ph":1349,"pw":1080,"pid":6238576,"ureported":null},{"pw":1080,"gid":0,"closest":6169379,"ph":1920,"ureported":null,"pid":6238577,"reported":"0","tags":"","similarity":272,"new":0},{"closest":6169379,"gid":0,"ph":1343,"pw":1080,"pid":6238578,"ureported":null,"reported":"0","new":0,"similarity":262,"tags":""},{"reported":"0","tags":"","similarity":253,"new":0,"pw":1080,"closest":6169395,"gid":0,"ph":1236,"ureported":null,"pid":6238579},{"ureported":null,"pid":6238580,"pw":1080,"gid":0,"ph":1080,"closest":6169395,"similarity":256,"tags":"","new":0,"reported":"0"},{"ureported":null,"pid":6238581,"pw":1080,"ph":1919,"gid":0,"closest":6169395,"tags":"","similarity":259,"new":0,"reported":"0"},{"pw":1080,"ph":1919,"gid":0,"closest":6238580,"ureported":null,"pid":6238582,"reported":"0","tags":"","similarity":263,"new":0},{"reported":"0","tags":"","similarity":255,"new":0,"pw":1080,"gid":0,"ph":1350,"closest":6169395,"ureported":null,"pid":6238583},{"reported":"0","new":0,"similarity":257,"tags":"","gid":0,"ph":1920,"closest":6169395,"pw":1080,"pid":6238584,"ureported":null},{"reported":"0","new":0,"tags":"","similarity":265,"gid":0,"closest":6169395,"ph":1920,"pw":1080,"pid":6238585,"ureported":null},{"gid":0,"ph":1920,"closest":6150706,"pw":1080,"pid":6169287,"ureported":null,"reported":"0","new":0,"tags":"","similarity":351},{"pid":6169288,"ureported":null,"gid":0,"ph":1920,"closest":6150706,"pw":1080,"new":0,"similarity":333,"tags":"","reported":"0"},{"new":0,"similarity":328,"tags":"","reported":"0","pid":6169289,"ureported":null,"ph":1920,"gid":0,"closest":6169288,"pw":1080},{"reported":"0","tags":"","similarity":318,"new":0,"pw":1080,"gid":0,"closest":6169288,"ph":1920,"ureported":null,"pid":6169290},{"pw":1080,"closest":6169288,"gid":0,"ph":1919,"ureported":null,"pid":6169291,"reported":"0","similarity":321,"tags":"","new":0},{"reported":"0","similarity":322,"tags":"","new":0,"pw":1080,"gid":0,"ph":1919,"closest":6169288,"ureported":null,"pid":6169292},{"pid":6169293,"ureported":null,"gid":0,"ph":1920,"closest":6169288,"pw":1080,"new":0,"similarity":326,"tags":"","reported":"0"},{"ureported":null,"pid":6169294,"pw":1080,"gid":0,"closest":6169288,"ph":1920,"similarity":319,"tags":"","new":0,"reported":"0"},{"new":0,"tags":"","similarity":322,"reported":"0","pid":6169295,"ureported":null,"closest":6169288,"gid":0,"ph":1920,"pw":1080},{"pw":1284,"gid":0,"closest":6169288,"ph":2282,"ureported":null,"pid":6169296,"reported":"0","tags":"","similarity":325,"new":0},{"tags":"","similarity":324,"new":0,"reported":"0","ureported":null,"pid":6169297,"pw":1284,"closest":6169288,"gid":0,"ph":2282},{"closest":6169288,"gid":0,"ph":2282,"pw":1284,"pid":6169298,"ureported":null,"reported":"0","new":0,"similarity":328,"tags":""},{"pw":1284,"ph":2282,"gid":0,"closest":6169288,"ureported":null,"pid":6169299,"reported":"0","tags":"","similarity":320,"new":0},{"new":0,"similarity":313,"tags":"","reported":"0","pid":6169300,"ureported":null,"closest":6169288,"gid":0,"ph":2282,"pw":1284},{"tags":"","similarity":317,"new":0,"reported":"0","ureported":null,"pid":6169301,"pw":1284,"closest":6169288,"gid":0,"ph":2282},{"pid":6169302,"ureported":null,"ph":1649,"gid":0,"closest":6169288,"pw":1440,"new":0,"tags":"","similarity":323,"reported":"0"},{"pw":1440,"closest":6169288,"gid":0,"ph":1649,"ureported":null,"pid":6169303,"reported":"0","similarity":322,"tags":"","new":0},{"ureported":null,"pid":6169304,"pw":1440,"gid":0,"ph":1649,"closest":6169288,"similarity":315,"tags":"","new":0,"reported":"0"},{"tags":"","similarity":318,"new":0,"reported":"0","ureported":null,"pid":6169305,"pw":1440,"closest":6169288,"gid":0,"ph":1578},{"reported":"0","new":0,"tags":"","similarity":317,"closest":6169288,"gid":0,"ph":1705,"pw":1440,"pid":6169306,"ureported":null},{"ureported":null,"pid":6169307,"pw":1440,"gid":0,"closest":6169288,"ph":1800,"tags":"","similarity":315,"new":0,"reported":"0"},{"new":0,"tags":"","similarity":317,"reported":"0","pid":6169308,"ureported":null,"ph":1800,"gid":0,"closest":6169288,"pw":1440},{"gid":0,"ph":2282,"closest":6169288,"pw":1284,"pid":6169309,"ureported":null,"reported":"0","new":0,"similarity":329,"tags":""},{"reported":"0","new":0,"similarity":329,"tags":"","gid":0,"ph":2282,"closest":6169288,"pw":1284,"pid":6169310,"ureported":null},{"reported":"0","tags":"","similarity":318,"new":0,"pw":1284,"ph":2282,"gid":0,"closest":6169306,"ureported":null,"pid":6169311},{"reported":"0","new":0,"similarity":314,"tags":"","gid":0,"ph":2282,"closest":6169288,"pw":1284,"pid":6169312,"ureported":null},{"ureported":null,"pid":6169313,"pw":1284,"closest":6169288,"gid":0,"ph":2282,"tags":"","similarity":315,"new":0,"reported":"0"},{"new":0,"tags":"","similarity":324,"reported":"0","pid":6169314,"ureported":null,"gid":0,"closest":6169306,"ph":1800,"pw":1440},{"similarity":318,"tags":"","new":0,"reported":"0","ureported":null,"pid":6169315,"pw":1284,"gid":0,"closest":6169288,"ph":2282},{"pid":6169316,"ureported":null,"gid":0,"ph":1660,"closest":6169306,"pw":1440,"new":0,"similarity":321,"tags":"","reported":"0"},{"pid":6169317,"ureported":null,"gid":0,"closest":6169288,"ph":2282,"pw":1284,"new":0,"tags":"","similarity":315,"reported":"0"},{"tags":"","similarity":328,"new":0,"reported":"0","ureported":null,"pid":6169318,"pw":1284,"gid":0,"closest":6169296,"ph":2282},{"closest":6169318,"gid":0,"ph":2282,"pw":1284,"pid":6169319,"ureported":null,"reported":"0","new":0,"tags":"","similarity":322},{"reported":"0","new":0,"tags":"","similarity":325,"closest":6169291,"gid":0,"ph":2282,"pw":1284,"pid":6169320,"ureported":null},{"ph":2282,"gid":0,"closest":6169320,"pw":1284,"pid":6169321,"ureported":null,"reported":"0","new":0,"similarity":314,"tags":""},{"reported":"0","new":0,"tags":"","similarity":319,"ph":2282,"gid":0,"closest":6169288,"pw":1284,"pid":6169322,"ureported":null},{"ph":1632,"gid":0,"closest":6169322,"pw":1440,"pid":6169323,"ureported":null,"reported":"0","new":0,"similarity":297,"tags":""},{"closest":6169322,"gid":0,"ph":1630,"pw":1440,"pid":6169324,"ureported":null,"reported":"0","new":0,"tags":"","similarity":302},{"similarity":277,"tags":"","new":0,"reported":"0","ureported":null,"pid":6169325,"pw":1440,"ph":1630,"gid":0,"closest":6169324},{"reported":"0","similarity":274,"tags":"","new":0,"pw":1440,"gid":0,"ph":1605,"closest":6169324,"ureported":null,"pid":6169326},{"reported":"0","similarity":269,"tags":"","new":0,"pw":1440,"gid":0,"ph":1799,"closest":6169324,"ureported":null,"pid":6169327},{"tags":"","similarity":276,"new":0,"reported":"0","ureported":null,"pid":6169328,"pw":1440,"gid":0,"ph":1800,"closest":6169324},{"new":0,"similarity":284,"tags":"","reported":"0","pid":6169329,"ureported":null,"gid":0,"closest":6169325,"ph":2282,"pw":1284},{"new":0,"similarity":281,"tags":"","reported":"0","pid":6169330,"ureported":null,"gid":0,"ph":2282,"closest":6169324,"pw":1284},{"ureported":null,"pid":6169331,"pw":1284,"gid":0,"closest":6169324,"ph":2282,"tags":"","similarity":283,"new":0,"reported":"0"},{"reported":"0","tags":"","similarity":279,"new":0,"pw":1284,"gid":0,"ph":2282,"closest":6169324,"ureported":null,"pid":6169332},{"ureported":null,"pid":6169333,"pw":1284,"gid":0,"ph":2282,"closest":6169324,"tags":"","similarity":274,"new":0,"reported":"0"},{"pid":6169334,"ureported":null,"ph":1800,"gid":0,"closest":6169324,"pw":1440,"new":0,"similarity":276,"tags":"","reported":"0"},{"reported":"0","new":0,"similarity":278,"tags":"","gid":0,"closest":6169324,"ph":2282,"pw":1284,"pid":6169335,"ureported":null},{"pid":6169336,"ureported":null,"gid":0,"ph":1777,"closest":6169324,"pw":1440,"new":0,"tags":"","similarity":274,"reported":"0"},{"pid":6169337,"ureported":null,"ph":1777,"gid":0,"closest":6169324,"pw":1440,"new":0,"similarity":281,"tags":"","reported":"0"},{"ureported":null,"pid":6169338,"pw":1440,"closest":6169324,"gid":0,"ph":1800,"similarity":281,"tags":"","new":0,"reported":"0"},{"ureported":null,"pid":6169339,"pw":1440,"gid":0,"closest":6169324,"ph":1799,"tags":"","similarity":277,"new":0,"reported":"0"},{"pid":6169340,"ureported":null,"gid":0,"closest":6169324,"ph":1406,"pw":1125,"new":0,"tags":"","similarity":296,"reported":"0"},{"gid":0,"ph":1800,"closest":6169324,"pw":1440,"pid":6169341,"ureported":null,"reported":"0","new":0,"similarity":286,"tags":""},{"pw":1440,"closest":6169324,"gid":0,"ph":1659,"ureported":null,"pid":6169343,"reported":"0","similarity":276,"tags":"","new":0},{"pw":1440,"closest":6169324,"gid":0,"ph":1656,"ureported":null,"pid":6169344,"reported":"0","similarity":274,"tags":"","new":0},{"reported":"0","new":0,"tags":"","similarity":279,"closest":6169324,"gid":0,"ph":1769,"pw":1440,"pid":6169345,"ureported":null},{"tags":"","similarity":277,"new":0,"reported":"0","ureported":null,"pid":6169346,"pw":1440,"gid":0,"closest":6169324,"ph":1775},{"new":0,"tags":"","similarity":281,"reported":"0","pid":6169347,"ureported":null,"closest":6169324,"gid":0,"ph":1771,"pw":1440},{"closest":6169325,"gid":0,"ph":1562,"pw":1249,"pid":6169348,"ureported":null,"reported":"0","new":0,"tags":"","similarity":267},{"pw":1247,"ph":1557,"gid":0,"closest":6169325,"ureported":null,"pid":6169349,"reported":"0","similarity":269,"tags":"","new":0},{"ureported":null,"pid":6169350,"pw":882,"gid":0,"closest":6169325,"ph":759,"tags":"","similarity":276,"new":0,"reported":"0"},{"reported":"0","new":0,"tags":"","similarity":280,"gid":0,"ph":760,"closest":6169324,"pw":882,"pid":6169351,"ureported":null},{"reported":"0","new":0,"similarity":277,"tags":"","closest":6169324,"gid":0,"ph":1800,"pw":1440,"pid":6169352,"ureported":null},{"pw":1440,"closest":6169324,"gid":0,"ph":1799,"ureported":null,"pid":6169353,"reported":"0","similarity":281,"tags":"","new":0},{"ph":1800,"gid":0,"closest":6169353,"pw":1440,"pid":6169354,"ureported":null,"reported":"0","new":0,"similarity":294,"tags":""},{"similarity":285,"tags":"","new":0,"reported":"0","ureported":null,"pid":6169355,"pw":1440,"gid":0,"closest":6169353,"ph":1799},{"reported":"0","new":0,"tags":"","similarity":279,"gid":0,"closest":6169324,"ph":1799,"pw":1440,"pid":6169356,"ureported":null},{"pw":1440,"gid":0,"closest":6169353,"ph":1799,"ureported":null,"pid":6169357,"reported":"0","tags":"","similarity":285,"new":0},{"reported":"0","tags":"","similarity":286,"new":0,"pw":1440,"gid":0,"closest":6169324,"ph":1799,"ureported":null,"pid":6169358},{"ureported":null,"pid":6169359,"pw":1440,"closest":6169324,"gid":0,"ph":1800,"tags":"","similarity":274,"new":0,"reported":"0"},{"similarity":273,"tags":"","new":0,"reported":"0","ureported":null,"pid":6169360,"pw":1440,"gid":0,"ph":1800,"closest":6169325},{"tags":"","similarity":279,"new":0,"reported":"0","ureported":null,"pid":6169361,"pw":1440,"ph":1795,"gid":0,"closest":6169324},{"pw":1440,"gid":0,"closest":6169325,"ph":1800,"ureported":null,"pid":6169362,"reported":"0","tags":"","similarity":273,"new":0},{"new":0,"tags":"","similarity":278,"reported":"0","pid":6169363,"ureported":null,"ph":1800,"gid":0,"closest":6169362,"pw":1440},{"ph":1800,"gid":0,"closest":6169362,"pw":1440,"pid":6169364,"ureported":null,"reported":"0","new":0,"similarity":278,"tags":""},{"pid":6169365,"ureported":null,"gid":0,"closest":6169362,"ph":1799,"pw":1440,"new":0,"similarity":273,"tags":"","reported":"0"},{"ureported":null,"pid":6169366,"pw":1440,"closest":6169362,"gid":0,"ph":1799,"tags":"","similarity":273,"new":0,"reported":"0"},{"pw":1440,"closest":6169324,"gid":0,"ph":1799,"ureported":null,"pid":6169367,"reported":"0","similarity":275,"tags":"","new":0},{"ureported":null,"pid":6169368,"pw":1440,"gid":0,"closest":6169324,"ph":1800,"tags":"","similarity":272,"new":0,"reported":"0"},{"ureported":null,"pid":6169369,"pw":1440,"gid":0,"ph":1800,"closest":6169324,"similarity":274,"tags":"","new":0,"reported":"0"},{"pw":1440,"closest":6169362,"gid":0,"ph":1799,"ureported":null,"pid":6169370,"reported":"0","similarity":274,"tags":"","new":0},{"closest":6169362,"gid":0,"ph":1799,"pw":1440,"pid":6169371,"ureported":null,"reported":"0","new":0,"similarity":269,"tags":""},{"gid":0,"ph":1800,"closest":6169371,"pw":1440,"pid":6169372,"ureported":null,"reported":"0","new":0,"similarity":273,"tags":""},{"closest":6169371,"gid":0,"ph":1800,"pw":1440,"pid":6169373,"ureported":null,"reported":"0","new":0,"similarity":269,"tags":""},{"reported":"0","new":0,"similarity":275,"tags":"","ph":1800,"gid":0,"closest":6169371,"pw":1440,"pid":6169374,"ureported":null},{"ureported":null,"pid":6169375,"pw":1440,"ph":1800,"gid":0,"closest":6169371,"similarity":274,"tags":"","new":0,"reported":"0"},{"ph":1795,"gid":0,"closest":6169324,"pw":1440,"pid":6169376,"ureported":null,"reported":"0","new":0,"tags":"","similarity":284},{"pid":6169377,"ureported":null,"closest":6169371,"gid":0,"ph":1795,"pw":1440,"new":0,"similarity":271,"tags":"","reported":"0"},{"pw":1440,"gid":0,"ph":1799,"closest":6169324,"ureported":null,"pid":6169378,"reported":"0","similarity":277,"tags":"","new":0},{"gid":0,"ph":1800,"closest":6169353,"pw":1440,"pid":6169379,"ureported":null,"reported":"0","new":0,"similarity":287,"tags":""},{"closest":6169371,"gid":0,"ph":1675,"pw":1440,"pid":6169380,"ureported":null,"reported":"0","new":0,"similarity":268,"tags":""},{"pid":6169381,"ureported":null,"gid":0,"ph":1800,"closest":6169379,"pw":1440,"new":0,"tags":"","similarity":266,"reported":"0"},{"pid":6169382,"ureported":null,"closest":6169379,"gid":0,"ph":1800,"pw":1440,"new":0,"similarity":264,"tags":"","reported":"0"},{"similarity":269,"tags":"","new":0,"reported":"0","ureported":null,"pid":6169383,"pw":1440,"gid":0,"ph":1800,"closest":6169379},{"gid":0,"ph":1800,"closest":6169379,"pw":1440,"pid":6169384,"ureported":null,"reported":"0","new":0,"tags":"","similarity":262},{"new":0,"similarity":271,"tags":"","reported":"0","pid":6169385,"ureported":null,"gid":0,"ph":1732,"closest":6169379,"pw":1440},{"reported":"0","tags":"","similarity":267,"new":0,"pw":1440,"gid":0,"closest":6169371,"ph":1457,"ureported":null,"pid":6169386},{"reported":"0","tags":"","similarity":270,"new":0,"pw":1440,"gid":0,"ph":1800,"closest":6169371,"ureported":null,"pid":6169387},{"ureported":null,"pid":6169389,"pw":1440,"ph":1650,"gid":0,"closest":6169379,"similarity":260,"tags":"","new":0,"reported":"0"},{"reported":"0","new":0,"similarity":266,"tags":"","gid":0,"closest":6169362,"ph":1641,"pw":1440,"pid":6169390,"ureported":null},{"reported":"0","similarity":265,"tags":"","new":0,"pw":1440,"gid":0,"ph":1791,"closest":6169379,"ureported":null,"pid":6169391},{"tags":"","similarity":266,"new":0,"reported":"0","ureported":null,"pid":6169392,"pw":1440,"ph":1800,"gid":0,"closest":6169379},{"new":0,"similarity":273,"tags":"","reported":"0","pid":6169393,"ureported":null,"ph":1799,"gid":0,"closest":6169379,"pw":1440},{"reported":"0","new":0,"tags":"","similarity":270,"ph":1791,"gid":0,"closest":6169371,"pw":1440,"pid":6169394,"ureported":null},{"reported":"0","new":0,"similarity":263,"tags":"","gid":0,"closest":6169379,"ph":1800,"pw":1440,"pid":6169395,"ureported":null},{"tags":"","similarity":256,"new":0,"reported":"0","ureported":null,"pid":6169396,"pw":1440,"closest":6169395,"gid":0,"ph":1795},{"new":0,"similarity":264,"tags":"","reported":"0","pid":6169397,"ureported":null,"ph":1795,"gid":0,"closest":6169379,"pw":1440},{"ureported":null,"pid":6169398,"pw":1440,"ph":1795,"gid":0,"closest":6169395,"tags":"","similarity":257,"new":0,"reported":"0"},{"pid":6169399,"ureported":null,"closest":6169362,"gid":0,"ph":1920,"pw":1080,"new":0,"similarity":263,"tags":"","reported":"0"},{"new":0,"similarity":251,"tags":"","reported":"0","pid":6169400,"ureported":null,"gid":0,"closest":6169395,"ph":2282,"pw":1284},{"reported":"0","new":0,"similarity":266,"tags":"","gid":0,"ph":2282,"closest":6169379,"pw":1284,"pid":6182919,"ureported":null},{"reported":"0","similarity":272,"tags":"","new":0,"pw":908,"ph":1674,"gid":0,"closest":6169395,"ureported":null,"pid":6270033},{"pw":934,"gid":0,"ph":1252,"closest":6169395,"ureported":null,"pid":6270034,"reported":"0","tags":"","similarity":256,"new":0},{"new":0,"similarity":252,"tags":"","reported":"0","pid":6270035,"ureported":null,"closest":6169395,"gid":0,"ph":1329,"pw":889},{"pid":6312524,"ureported":null,"closest":6274307,"gid":0,"ph":1188,"pw":860,"new":0,"tags":"","similarity":245,"reported":"0"},{"pid":6150706,"ureported":null,"ph":1230,"gid":0,"closest":null,"pw":1080,"new":0,"similarity":null,"tags":"","reported":"0"},{"new":0,"tags":"","similarity":253,"reported":"0","pid":6274306,"ureported":null,"ph":1098,"gid":0,"closest":6169395,"pw":1125},{"pw":1125,"gid":0,"ph":1390,"closest":6169379,"ureported":null,"pid":6274307,"reported":"0","similarity":253,"tags":"","new":0},{"reported":"0","new":0,"tags":"","similarity":236,"closest":6274307,"gid":0,"ph":1380,"pw":1108,"pid":6402421,"ureported":null},{"reported":"0","new":0,"tags":"","similarity":235,"gid":0,"ph":1251,"closest":6274307,"pw":1125,"pid":6402422,"ureported":null},{"reported":"0","tags":"","similarity":240,"new":0,"pw":1125,"gid":0,"ph":1398,"closest":6169395,"ureported":null,"pid":6402423},{"similarity":252,"tags":"","new":1,"reported":"0","ureported":null,"pid":6421028,"pw":1125,"gid":0,"closest":6274307,"ph":1963},{"tags":"","similarity":232,"new":1,"reported":"0","ureported":null,"pid":6421029,"pw":1125,"ph":1892,"gid":0,"closest":6274307},{"new":1,"tags":"","similarity":265,"reported":"0","pid":6421030,"ureported":null,"ph":1952,"gid":0,"closest":6169395,"pw":1125}]; for (var i in messanger['gdata']) { messanger.pexist[messanger['gdata'][i].pid] = 1; if (messanger['gdata'][i].reported != '0') numreported++; } var hash = window.location.hash.substr(1); if (hash == 'reports') document.getElementById('gdatasort').value = 'rep'; if (getCookie('nophotos') == 'true') {} else pDisplayPage(0, 1); </script> </div>
-
Hi there, I've some existing post with wordpress custom field. I can create post with custom feild but now I want to update their custom field. How Can I get the post using Post Title & update their custom field data? Can anyone help plz?
-
On 6/30/2021 at 7:31 PM, cyberRobot said:
You could use a loop. For example,
$mcptitles = array("Volvo", "BMW", "Toyota"); foreach($mcptitles as $mcptitle) { //your existing code here... }
Note that I changed the name of variable that holds the array. That way it should hopefully work with your existing code. Also note that I didn't review your code since it sounds like it's working.
Sorry for late reply. Thanks for the suggestion. After I follow your example now I'm able to create multiple categories but it's not selecting all categories. It select only one category. Can you plz help me out how can I select all categories?
-
I've a code that can create category if not existed the category & add this to the post. If category already exist then it will select the category.
Here is my code snippet example :
$mcptitle = 'Lenevo xiaoxin pad pro 2021'; //Geting Brand Name $brands = $mcptitle; $arr = explode(' ',trim($mcptitle)); $brand= $arr[0]; //Notice Brand name Detected //category Slug $catlink=sanitize_title($brand); //Finding category by name & geting id if($term = get_term_by( 'name', $brand, 'category' ) ){ $cat_id= $term->term_id; }else{ //creating category for not exists category $terms= wp_insert_term($brand, // the term 'category', // the taxonomy array( 'slug' => $catlink )); //geting new category id $cat_id= $terms['term_id']; //post start $post = array( 'post_author' => 1, 'post_content' => $content, 'post_status' => "publish", 'post_title' => $title, 'post_type' => "post", ); $post_id = wp_insert_post( $post, $wp_error ); //seting category wp_set_object_terms( $post_id, $cat_id, 'category' );
That works for create/add one category But I want to add multiple categories in it. Category array will be like this: $mcptitle = array("Volvo", "BMW", "Toyota");
Plz Can anyone help me about my thoughts. Thanks in advance.
-
2 hours ago, Barand said:
The only difference that missing </div> makes is that the second find() returns the text up to the next </div>, thus giving
$name = "Name: madac" $age = "Age: 18 <div class='man'>Class: 12</div> " $cls = "Class: 12"
So you just need to look for and trim off the excess "<div> ... </div>"
Perhaps...
$html = str_get_html('<div> <div class="man">Name: madac</div> <div class="man">Age: 18 <div class="man">Class: 12</div> </div>'); $name = trim_html($html->find('div[class="man"]', 0)->innertext); $age = trim_html($html->find('div[class="man"]', 1)->innertext); $cls = trim_html($html->find('div[class="man"]', 2)->innertext); function trim_html($str) { if ( ($p = strpos($str, '<')) !== false) { $str = substr($str, 0, $p); } return trim($str); }
I've tried your code. That's amazingly worked for me. Thank you so much.
-
2 hours ago, requinix said:
A website that you control? Someone else's? Can you tell them to fix their markup so that it's, you know, syntactically valid HTML?
That's a government site. I've no access to the site.
-
16 minutes ago, requinix said:
Add the closing div tag? Where is the HTML coming from?
From a website
-
require_once 'phpSimpleHtmlDomClass.php'; $html = '<div> <div class="man">Name: madac</div> <div class="man">Age: 18 <div class="man">Class: 12</div> </div>' $name=$html->find('div[class="man"]', 0)->innertext; $age=$html->find('div[class="man"]', 1)->innertext; $cls=$html->find('div[class="man"]', 2)->innertext;
wanna get a text from each div class="man" but it didn't work because there is a missing closing div tag on 2nd line of html code. please help me to fix this.
thanks in advance.
How to find post if thumbnail is empty (wordpress)
in PHP Coding Help
Posted · Edited by shaadamin44
Hi, I've more Than 5000 post on my wordpress site but some of the post have no thumbnail. I'm looking for a wp function that give me the post id if the post have no thumbnail. Can anyone write me the code?