[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Вырезать див
RCuPeR
Помогите составить регулярку которая сможет вырезать все, что находится в div'e <div id="page-container">. Спасибо.



Спустя 1 час, 2 минуты, 24 секунды (30.10.2011 - 14:56) Invis1ble написал(а):
Свои наработки? Или опять хочешь, чтоб за тебя сделали, т.к. у тебя "времени нет" ?

Спустя 22 минуты, 9 секунд (30.10.2011 - 15:18) RCuPeR написал(а):
preg_match_all(
"/<form id=\"phx-signup-form\">(.*)<\/form>/isU",
$html, $matches_art, PREG_PATTERN_ORDER);

print_r($matches_art);

Возвращает пустой массив.

Спустя 5 минут, 50 секунд (30.10.2011 - 15:24) Invis1ble написал(а):
И где в твоей регулярке div ?

Спустя 5 минут, 36 секунд (30.10.2011 - 15:30) RCuPeR написал(а):
Ну, див уже трансформировался в форму. Подумал, что див будет лишним, решил резануть форму.

Спустя 1 минута, 24 секунды (30.10.2011 - 15:31) RCuPeR написал(а):
Суть вопроса от этого не меняется.

Свернутый текст
<form id="phx-signup-form" method="POST" action="https://twitter.com/account/create" class="">
<input
type="hidden" value="" name="authenticity_token">








<fieldset
class="textbox">

<div
class="prompt name">
<div
class="holding hasome" data-fieldname="name">
<div
class="sidetip">

<p
class="ok isaok">Name looks great.</p>
<p
class="tip">Enter your first and last name.</p>
<p
class="blank invalid error" role="alert">A name is required!</p>
</div>
<input
type="text" autocomplete="off" value="RomanOST" name="user[name]" maxlength="20" aria-required="true">
<span
class="holder">Full name</span>
</div>
</div>

<div
class="prompt email">
<div
class="holding hasome" data-fieldname="email">
<div
class="sidetip">

<p
class="tip">What’s your email address?</p>
<p
class="ok isaok">We will email you a confirmation.</p>
<p
class="checking">Validating...</p>
<p
class="invalid error" role="alert">Doesn't look like a valid email.</p>
<p
class="blank error" role="alert">An email is required!</p>
<p
class="taken error" role="alert">This email is already registered. Want to <a href="/login">login</a> or <a href="/account/resend_password">recover your password</a>?</p>
</div>
<input
type="text" autocomplete="off" value="cuper2@mail.ru" name="user[email]" aria-required="true">
<span
class="holder">Email</span>
</div>
</div>

<div
class="prompt password">
<div
class="holding hasome" data-fieldname="password">
<div
class="sidetip">

<p
class="tip">6 characters or more! Be tricky.</p>
<p
class="perfect isaok">Password is perfect!</p>
<p
class="ok isaok">Password is okay.</p>
<p
class="weak isaok">Password could be more secure.</p>
<p
class="weak error" role="alert">Password is not secure enough.</p>
<p
class="obvious error" role="alert">Password is too obvious.</p>
<p
class="invalid error" role="alert">Password must be at least 6 characters. No whitespace.</p>
<p
class="blank error" role="alert">Password cannot be blank!</p>
</div>
<input
type="password" value="2roma541574" name="user[user_password]" aria-required="true">
<span
class="holder">Password</span>
</div>

<div
class="score"><span><b></b></span></div>

</div>

<div
class="prompt username">
<div
class="holding hasome" data-fieldname="username">
<div
class="sidetip">

<p
class="ok isaok">Username is available.</p>
<p
class="tip">Don't worry, you can change it later.</p>
<p
class="checking">Validating...</p>
<p
class="taken error" role="alert">This username is already taken!</p>
<p
class="invalid error" role="alert">Invalid username! Alphanumerics only.</p>
<p
class="blank error" role="alert">A username is required!</p>
</div>
<input
type="text" autocomplete="off" value="RomanOST1" data-pre-input-value="RomanOST1" name="user[screen_name]" maxlength="15" aria-required="true">
<span
class="holder">Username</span>
</div>
<div
class="suggestions">Suggestions: <ul></ul></div>
</div>


<div
class="prompt rememberme">
<label>
<input
type="checkbox" checked="checked" name="user[remember_me_on_signup]" value="1">
<span>
Keep me logged-in on this computer.</span>
</label>
<input
type="hidden" name="user[remember_me_on_signup]" value="">
</div>

<input
type="hidden" name="context" value="">

</fieldset>

<div
class="tos">
<div
class="sidetip">
<p
class="active tip">Printable versions:<br><a href="/tos" target="_blank">Terms of Service</a> · <a href="/privacy" target="_blank">Privacy Policy</a></p>
</div>
<div
class="scroller">
<p
class="header">By clicking the button, you agree to the terms below:</p>
<div
class="import">
<h2>
Terms of Service</h2>


<p>
These Terms of Service ("<strong>Terms</strong>") govern your access to and use of the services and Twitter’s websites (the "<strong>Services</strong>"), and any information, text, graphics, photos or other materials uploaded, downloaded or appearing on the Services (collectively referred to as "<strong>Content</strong>"). Your access to and use of the Services is conditioned on your acceptance of and compliance with these Terms. By accessing or using the Services you agree to be bound by these Terms.
</p>

<h3>
Basic Terms</h3>

<p>
You are responsible for your use of the Services, for any Content you post to the Services, and for any consequences thereof. The Content you submit, post, or display will be able to be viewed by other users of the Services and through third party services and websites (go to the <a href="/settings/account">account settings</a> page to control who sees your Content). You should only provide Content that you are comfortable sharing with others under these Terms.</p>

<p
class="tip"><span class="tip">Tip</span> What you say on Twitter may be viewed all around the world instantly. You are what you Tweet!</p>

<p>
You may use the Services only if you can form a binding contract with Twitter and are not a person barred from receiving services under the laws of the United States or other applicable jurisdiction. You may use the Services only in compliance with these Terms and all applicable local, state, national, and international laws, rules and regulations.</p>

<p>
The Services that Twitter provides are always evolving and the form and nature of the Services that Twitter provides may change from time to time without prior notice to you. In addition, Twitter may stop (permanently or temporarily) providing the Services (or any features within the Services) to you or to users generally and may not be able to provide you with prior notice. We also retain the right to create limits on use and storage at our sole discretion at any time without prior notice to you.</p>

<p>
The Services may include advertisements, which may be targeted to the Content or information on the Services, queries made through the Services, or other information. The types and extent of advertising by Twitter on the Services are subject to change. In consideration for Twitter granting you access to and use of the Services, you agree that Twitter and its third party providers and partners may place such advertising on the Services or in connection with the display of Content or information from the Services whether submitted by you or others.</p>

<h3>
Privacy</h3>


<p>
Any information that you provide to Twitter is subject to our <a href="/privacy">Privacy Policy</a>, which governs our collection and use of your information. You understand that through your use of the Services you consent to the collection and use (as set forth in the Privacy Policy) of this information, including the transfer of this information to the United States and/or other countries for storage, processing and use by Twitter. As part of providing you the Services, we may need to provide you with certain communications, such as service announcements and administrative messages. These communications are considered part of the Services and your Twitter account, which you may not be able to opt-out from receiving.</p>

<p
class="tip"><span class="tip">Tip</span> You can opt-out of most communications from Twitter including our newsletter, new follower emails, etc. Please see the Notifications tab of Settings for more.</p>

<h3>
Passwords</h3>

<p>
You are responsible for safeguarding the password that you use to access the Services and for any activities or actions under your password. We encourage you to use "strong" passwords (passwords that use a combination of upper and lower case letters, numbers and symbols) with your account. Twitter cannot and will not be liable for any loss or damage arising from your failure to comply with the above requirements.</p>

<h3>
Content on the Services</h3>

<p>
All Content, whether publicly posted or privately transmitted, is the sole responsibility of the person who originated such Content. We may not monitor or control the Content posted via the Services and, we cannot take responsibility for such Content. Any use or reliance on any Content or materials posted via the Services or obtained by you through the Services is at your own risk.</p>

<p>
We do not endorse, support, represent or guarantee the completeness, truthfulness, accuracy, or reliability of any Content or communications posted via the Services or endorse any opinions expressed via the Services. You understand that by using the Services, you may be exposed to Content that might be offensive, harmful, inaccurate or otherwise inappropriate, or in some cases, postings that have been mislabeled or are otherwise deceptive. Under no circumstances will Twitter be liable in any way for any Content, including, but not limited to, any errors or omissions in any Content, or any loss or damage of any kind incurred as a result of the use of any Content posted, emailed, transmitted or otherwise made available via the Services or broadcast elsewhere.</p>

<h3>
Your Rights</h3>

<p>
You retain your rights to any Content you submit, post or display on or through the Services. By submitting, posting or displaying Content on or through the Services, you grant us a worldwide, non-exclusive, royalty-free license (with the right to sublicense) to use, copy, reproduce, process, adapt, modify, publish, transmit, display and distribute such Content in any and all media or distribution methods (now known or later developed).</p>

<p
class="tip"><span class="tip">Tip</span> This license is you authorizing us to make your Tweets available to the rest of the world and to let others do the same.</p>

<p>
You agree that this license includes the right for Twitter to make such Content available to other companies, organizations or individuals who partner with Twitter for the syndication, broadcast, distribution or publication of such Content on other media and services, subject to our terms and conditions for such Content use. </p>


<p
class="tip"><span class="tip">Tip</span> Twitter has an evolving set of <a href="/apirules">rules</a> for how ecosystem partners can interact with your content. These rules exist to enable an open ecosystem with your rights in mind. But what’s yours is yours – you own your Content (and your photos are part of that Content)</p>

<p>
Such additional uses by Twitter, or other companies, organizations or individuals who partner with Twitter, may be made with no compensation paid to you with respect to the Content that you submit, post, transmit or otherwise make available through the Services.</p>

<p>
We may modify or adapt your Content in order to transmit, display or distribute it over computer networks and in various media and/or make changes to your Content as are necessary to conform and adapt that Content to any requirements or limitations of any networks, devices, services or media.</p>

<p>
You are responsible for your use of the Services, for any Content you provide, and for any consequences thereof, including the use of your Content by other users and our third party partners. You understand that your Content may be rebroadcasted by our partners and if you do not have the right to submit Content for such use, it may subject you to liability. Twitter will not be responsible or liable for any use of your Content by Twitter in accordance with these Terms. You represent and warrant that you have all the rights, power and authority necessary to grant the rights granted herein to any Content that you submit.</p>

<p>
Twitter gives you a personal, worldwide, royalty-free, non-assignable and non-exclusive license to use the software that is provided to you by Twitter as part of the Services. This license is for the sole purpose of enabling you to use and enjoy the benefit of the Services as provided by Twitter, in the manner permitted by these Terms.</p>

<h3>
Twitter Rights</h3>

<p>
All right, title, and interest in and to the Services (excluding Content provided by users) are and will remain the exclusive property of Twitter and its licensors. The Services are protected by copyright, trademark, and other laws of both the United States and foreign countries. Nothing in the Terms gives you a right to use the Twitter name or any of the Twitter trademarks, logos, domain names, and other distinctive brand features. Any feedback, comments, or suggestions you may provide regarding Twitter, or the Services is entirely voluntary and we will be free to use such feedback, comments or suggestions as we see fit and without any obligation to you.</p>

<h3>
Restrictions on Content and Use of the Services</h3>


<p>
We reserve the right at all times (but will not have an obligation) to remove or refuse to distribute any Content on the Services and to terminate users or reclaim usernames. Please review the <a href="http://support.twitter.com/articles/18311-the-twitter-rules">Twitter Rules</a> (which are part of these Terms) to better understand what is prohibited on the Service. We also reserve the right to access, read, preserve, and disclose any information as we reasonably believe is necessary to (i) satisfy any applicable law, regulation, legal process or governmental request, (ii) enforce the Terms, including investigation of potential violations hereof, (iii) detect, prevent, or otherwise address fraud, security or technical issues, (iv) respond to user support requests, or (v) protect the rights, property or safety of Twitter, its users and the public.</p>

<p
class="tip"><span class="tip">Tip</span> Twitter does not disclose personally identifying information to third parties except in accordance with our Privacy Policy.</p>


<p>
Except as permitted through the Services (or these Terms), you have to use the <a href="http://dev.twitter.com">Twitter API</a> if you want to reproduce, modify, create derivative works, distribute, sell, transfer, publicly display, publicly perform, transmit, or otherwise use the Content or Services.</p>

<p
class="tip"><span class="tip">Tip</span> We encourage and permit broad re-use of Content. The Twitter API exists to enable this.</p>

<p>
You may not do any of the following while accessing or using the Services: (i) access, tamper with, or use non-public areas of the Services, Twitter’s computer systems, or the technical delivery systems of Twitter’s providers; (ii) probe, scan, or test the vulnerability of any system or network or breach or circumvent any security or authentication measures; (iii) access or search or attempt to access or search the Services by any means (automated or otherwise) other than through our currently available, published interfaces that are provided by Twitter (and only pursuant to those terms and conditions), unless you have been specifically allowed to do so in a separate agreement with Twitter (NOTE: crawling the Services is permissible if done in accordance with the provisions of the robots.txt file, however, scraping the Services without the prior consent of Twitter is expressly prohibited); (iv) forge any TCP/IP packet header or any part of the header information in any email or posting, or in any way use the Services to send altered, deceptive or false source-identifying information; or (v) interfere with, or disrupt, (or attempt to do so), the access of any user, host or network, including, without limitation, sending a virus, overloading, flooding, spamming, mail-bombing the Services, or by scripting the creation of Content in such a manner as to interfere with or create an undue burden on the Services.</p>

<h3>
Copyright Policy</h3>

<p>
Twitter respects the intellectual property rights of others and expects users of the Services to do the same. We will respond to notices of alleged copyright infringement that comply with applicable law and are properly provided to us. If you believe that your Content has been copied in a way that constitutes copyright infringement, please provide us with the following information: (i) a physical or electronic signature of the copyright owner or a person authorized to act on their behalf; (ii) identification of the copyrighted work claimed to have been infringed; (iii) identification of the material that is claimed to be infringing or to be the subject of infringing activity and that is to be removed or access to which is to be disabled, and information reasonably sufficient to permit us to locate the material; (iv) your contact information, including your address, telephone number, and an email address; (v) a statement by you that you have a good faith belief that use of the material in the manner complained of is not authorized by the copyright owner, its agent, or the law; and (vi) a statement that the information in the notification is accurate, and, under penalty of perjury, that you are authorized to act on behalf of the copyright owner.</p>

<p>
We reserve the right to remove Content alleged to be infringing without prior notice and at our sole discretion. In appropriate circumstances, Twitter will also terminate a user’s account if the user is determined to be a repeat infringer. Our designated copyright agent for notice of alleged copyright infringement appearing on the Services is:</p>

<address>
Twitter, Inc. <br> Attn: Copyright Agent <br> 795 Folsom Street, Suite 600 <br> San Francisco, CA 94107 <br> Email: <a href="mailto:copyright@twitter.com">copyright@twitter.com</a></address>

<h3>
The Services are Available "AS-IS"</h3>
<p>
Your access to and use of the Services or any Content is at your own risk. You understand and agree that the Services is provided to you on an "AS IS" and "AS AVAILABLE" basis. Without limiting the foregoing, TWITTER AND ITS PARTNERS DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. We make no warranty and disclaim all responsibility and liability for the completeness, accuracy, availability, timeliness, security or reliability of the Services or any content thereon. Twitter will not be responsible or liable for any harm to your computer system, loss of data, or other harm that results from your access to or use of the Services, or any Content. You also agree that Twitter has no responsibility or liability for the deletion of, or the failure to store or to transmit, any Content and other communications maintained by the Services. We make no warranty that the Services will meet your requirements or be available on an uninterrupted, secure, or error-free basis. No advice or information, whether oral or written, obtained from Twitter or through the Services, will create any warranty not expressly made herein.</p>

<h3>
Links</h3>
<p>
The Services may contain links to third-party websites or resources. You acknowledge and agree that we are not responsible or liable for: (i) the availability or accuracy of such websites or resources; or (ii) the content, products, or services on or available from such websites or resources. Links to such websites or resources do not imply any endorsement by Twitter of such websites or resources or the content, products, or services available from such websites or resources. You acknowledge sole responsibility for and assume all risk arising from your use of any such websites or resources.</p>

<h3>
Limitation of Liability</h3>
<p>
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, TWITTER AND ITS SUBSIDIARIES, AFFILIATES, OFFICERS, EMPLOYEES, AGENTS, PARTNERS AND LICENSORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR PUNITIVE DAMAGES, INCLUDING WITHOUT LIMITATION, LOSS OF PROFITS, DATA, USE, GOOD-WILL, OR OTHER INTANGIBLE LOSSES, RESULTING FROM (i) YOUR ACCESS TO OR USE OF OR INABILITY TO ACCESS OR USE THE SERVICES; (ii) ANY CONDUCT OR CONTENT OF ANY THIRD PARTY ON THE SERVICES, INCLUDING WITHOUT LIMITATION, ANY DEFAMATORY, OFFENSIVE OR ILLEGAL CONDUCT OF OTHER USERS OR THIRD PARTIES; (iii) ANY CONTENT OBTAINED FROM THE SERVICES; AND (iv) UNAUTHORIZED ACCESS, USE OR ALTERATION OF YOUR TRANSMISSIONS OR CONTENT, WHETHER BASED ON WARRANTY, CONTRACT, TORT (INCLUDING NEGLIGENCE) OR ANY OTHER LEGAL THEORY, WHETHER OR NOT TWITTER HAS BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGE, AND EVEN IF A REMEDY SET FORTH HEREIN IS FOUND TO HAVE FAILED OF ITS ESSENTIAL PURPOSE.</p>

<h3>
Exclusions</h3>
<p>
Some jurisdictions do not allow the exclusion of certain warranties or the exclusion or limitation of liability for consequential or incidental damages, so the limitations above may not apply to you.</p>

<h3>
Waiver and Severability</h3>
<p>
The failure of Twitter to enforce any right or provision of these Terms will not be deemed a waiver of such right or provision. In the event that any provision of these Terms is held to be invalid or unenforceable, the remaining provisions of these Terms will remain in full force and effect.</p>

<h3>
Controlling Law and Jurisdiction</h3>
<p>
These Terms and any action related thereto will be governed by the laws of the State of California without regard to or application of its conflict of law provisions or your state or country of residence. All claims, legal proceedings or litigation arising in connection with the Services will be brought solely in San Francisco County, California, and you consent to the jurisdiction of and venue in such courts and waive any objection as to inconvenient forum. If you are accepting these Terms on behalf of a United States federal government entity that is legally unable to accept the controlling law, jurisdiction or venue clauses above, then those clauses do not apply to you but instead these Terms and any action related thereto will be will be governed by the laws of the United States of America (without reference to conflict of laws) and, in the absence of federal law and to the extent permitted under federal law, the laws of the State of California (excluding choice of law).</p>

<h3>
Entire Agreement</h3>
<p>
These Terms, the Twitter Rules and our Privacy Policy are the entire and exclusive agreement between Twitter and you regarding the Services (excluding any services for which you have a separate agreement with Twitter that is explicitly in addition or in place of these Terms), and these Terms supersede and replace any prior agreements between Twitter and you regarding the Services. Other than members of the group of companies of which Twitter is the parent, no other person or company will be third party beneficiaries to the Terms.</p>


<p>
We may revise these Terms from time to time, the most current version will always be at <a href="/tos">twitter.com/tos</a>. If the revision, in our sole discretion, is material we will notify you via an @Twitter update or e-mail to the email associated with your account. By continuing to access or use the Services after those revisions become effective, you agree to be bound by the revised Terms.</p>


<p>
These Services are operated and provided by Twitter Inc., 795 Folsom Street, Suite 600, San Francisco, CA 94107. If you have any questions about these Terms, please <a href="/about/contact">contact us</a>.</p>

<p><em>
Effective: June 01, 2011</em></p>
</div>
</div>

</div>



<div
class="standby">
<p>
Creating your account…</p>
</div>

<fieldset
class="doit">

<div
class="sign-up-box"><input class="submit button promotional" type="submit" value="Create my account"></div>

<div
class="befound">


<p>

Note: Others will be able to find you by name, username or email. Your email will not be shown publicly. You can change your privacy settings at any time.
</p>
<input
type="hidden" name="user[discoverable_by_email]" value="1">

</div>



<input
type="hidden" name="user[send_email_newsletter]" value="1">


</fieldset>


</form>


Вот форма.

Спустя 3 минуты, 43 секунды (30.10.2011 - 15:35) Invis1ble написал(а):
id у формы тоже "трансформировался"?
Помимо id у формы нет других атрибутов?


так правильно, у формы есть еще action, class и method, кроме id

Спустя 57 секунд (30.10.2011 - 15:36) RCuPeR написал(а):
Есть. Вот:
<form id="phx-signup-form" method="POST" action="https://twitter.com/account/create" class="">

Спустя 1 час, 37 минут, 35 секунд (30.10.2011 - 17:13) Игорь_Vasinsky написал(а):
ты у себя парсишь чтоли???
чёт я не понял в чём необходимость...

Спустя 1 час, 3 минуты, 34 секунды (30.10.2011 - 18:17) RCuPeR написал(а):
Есть HTML страница, курлому получаю себе ее содержимое, но, целая страница для моих потребностей - много. По-этому нужно вырезать только форму.

Спустя 1 минута, 39 секунд (30.10.2011 - 18:19) Игорь_Vasinsky написал(а):
ну так и паттерн простой

#<tag>(.*)</tag>#ius

а в чём проблема то?

Спустя 9 минут, 47 секунд (30.10.2011 - 18:28) RCuPeR написал(а):
#<form id=\"phx-signup-form\">(.*)</form>#ius

С айдишником так ?

Спустя 20 минут, 28 секунд (30.10.2011 - 18:49) Игорь_Vasinsky написал(а):
ну так. модификатор u - для юникода

Спустя 1 час, 27 минут, 21 секунда (30.10.2011 - 20:16) Winston написал(а):
Для начала напиши так
echo '<pre>'.htmlspecialchars(print_r($page, 1)).'</pre>';

И посмотри как там написан код формы, т.к. если ты смотришь исходный код страницы через браузер, то не исключено, что некоторые элементы местами сменены, на себе проверено...



Спустя 38 секунд Winston написал(а):
Цитата (RCuPeR @ 30.10.2011 - 18:28)
#<form id=\"phx-signup-form\">(.*)</form>#ius

С айдишником так ?

Вот так
#<form id=\"phx-signup-form\">(.*)</form>#iusU

Спустя 3 минуты, 20 секунд (30.10.2011 - 20:20) Игорь_Vasinsky написал(а):
а жадность зачем?

Спустя 13 минут, 14 секунд (30.10.2011 - 20:33) Winston написал(а):
Цитата (Игорь_Vasinsky @ 30.10.2011 - 20:20)
а жадность зачем?

Я отключил жадность, т.к. возможно, что у него не одна форма на странице..

Спустя 17 минут, 6 секунд (30.10.2011 - 20:50) Invis1ble написал(а):
Winston
Твоя регулярка не сработает у него, ибо у формы есть еще куча атрибутов, помимо id - см. мой пост выше.

Спустя 15 минут, 53 секунды (30.10.2011 - 21:06) Winston написал(а):
Invis1ble
Точняк !
RCuPeR если у тебя только одна форма на странице то достаточно
#<form[^>]*>(.*)</form>#sU

Спустя 1 час, 57 минут, 18 секунд (30.10.2011 - 23:03) RCuPeR написал(а):
Не, у меня несколько форм. А нужна форма с определенным id.

Свернутый текст
Сорри, что не отвечал.

Спустя 18 минут, 47 секунд (30.10.2011 - 23:22) Игорь_Vasinsky написал(а):
тогда в паттерне укажи полностью тег с атрибутами.

Спустя 27 минут, 43 секунды (30.10.2011 - 23:50) RCuPeR написал(а):
С этим, с вашей помощью, разобрался. Всем спасибо !

Спустя 38 минут, 43 секунды (31.10.2011 - 00:28) RCuPeR написал(а):
Мужики, можно я вас еще немного позадрачиваю ? :(

<input type="text" autocomplete="off" value="RomanOST1" data-pre-input-value="RomanOST1" name="user[screen_name]" maxlength="15" aria-required="true" />


Что бы получить value этого импута, должен быть составлен такой паттерн:
$pattern = '/<input name=\"user[screen_name]\" value=\"(.*)\"/>/isU';


?

Спустя 8 минут, 38 секунд (31.10.2011 - 00:37) Winston написал(а):
$pattern = '/<input[^>]*value=\"(.*)\".*name=\"user[screen_name]\"[^>]*/>/isU';

Спустя 9 минут, 21 секунда (31.10.2011 - 00:46) RCuPeR написал(а):
К сожалению, пусто. Ничего не вернуло.

Спустя 2 минуты, 58 секунд (31.10.2011 - 00:49) RCuPeR написал(а):
<?php

$str = '<input type="text" autocomplete="off" value="RomanOST1" data-pre-input-value="RomanOST1" name="user[screen_name]" maxlength="15" aria-required="true" />';
$pattern = '/<input name=\"user[screen_name]\" value=\"(.*)\"/>/isU';

preg_match_all($pattern, $str, $matchesarray);

print_r($matchesarray);


?>


Пусто.

Спустя 5 минут, 49 секунд (31.10.2011 - 00:55) Winston написал(а):
#<input[^>]*value="([^"]*)"[^>]*name="user\[screen_name\]"[^>]*/>#isU

Спустя 2 минуты, 49 секунд (31.10.2011 - 00:58) RCuPeR написал(а):
Работает ! Спасибо ! На сегодня все. Два основных примера регулярок собрал, думаю, дальше сам справлюсь. Если нет, дабы не создавать топик - буду отписывать сюда.

Спустя 11 часов, 29 минут, 9 секунд (1.11.2011 - 12:27) RCuPeR написал(а):
Я вернулся. Можно еще парочку вопросов ?

Существует строка вида
"profile_link_color":"CC3366","id_str":"325679866"

Как с нее получить 325679866 ?

Спустя 13 минут, 4 секунды (1.11.2011 - 12:40) RCuPeR написал(а):
preg_match_all('/\"profile_link_color\":\"CC3366\",\"id_str\":\(.*)\"/isU', $str, $match);
Я так понимаю, это оно ?

Спустя 7 минут, 30 секунд (1.11.2011 - 12:48) Winston написал(а):
Можно и так
preg_match('#(\d+)"$#', $str, $match);
print_r($match);

Спустя 3 минуты, 3 секунды (1.11.2011 - 12:51) RCuPeR написал(а):
Я так понимаю, что этот способ вырвет все цифры со строки ?

Спустя 2 минуты, 21 секунда (1.11.2011 - 12:53) Winston написал(а):
Не все, а только эти 325679866

Спустя 2 минуты, 27 секунд (1.11.2011 - 12:55) RCuPeR написал(а):
А можешь объяснить почему только эти ?

В принципе твой пример рабочий, но он чуть не подходит. Дело в том, что буду парсить JS код, из него мне нужно получить 325679866, самое удачное место где я могу это сделать, это эта строка $str = '"profile_link_color":"CC3366","id_str":"325679866"';

Спустя 2 минуты, 56 секунд (1.11.2011 - 12:58) RCuPeR написал(а):
Я бы даже изменил эту строку. Что-то типа такого:

$str = '"profile_link_color":"значение из 6-и символов","id_str":"325679866"'

Спустя 29 секунд (1.11.2011 - 12:59) Winston написал(а):
Цитата (RCuPeR @ 1.11.2011 - 11:55)
А можешь объяснить почему только эти ?

Цитата (RCuPeR @ 1.11.2011 - 11:27)
Существует строка вида
"profile_link_color":"CC3366","id_str":"325679866"
Как с нее получить 325679866 ?

Что захотел, то и получил smile.gif
Цитата (RCuPeR @ 1.11.2011 - 11:55)
Дело в том, что буду парсить JS код, из него мне нужно получить 325679866

Можешь показать больше JS кода ?

Спустя 9 минут, 36 секунд (1.11.2011 - 13:08) RCuPeR написал(а):
Цитата
Что захотел, то и получил

Точно :unsure:

Цитата
Можешь показать больше JS кода ?

Конечно. Вот, смотри:

Свернутый текст
provide('boot/bootstrap_data', function(exports) {
exports({"requestCacheSeedData":[{"api_request_name":"account\/verify_credentials","options":[{}],"json":{"profile_sidebar_border_color":"DBE9ED","profile_sidebar_fill_color":"E6F6F9","profile_background_tile":false,"name":"Roman Zorin","location":"\u0427\u0435\u0440\u043a\u0430\u0441\u0441\u044b","created_at":"Tue Jun 28 17:58:18 +0000 2011","profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1440208978\/jquery_normal.jpeg","is_translator":false,"follow_request_sent":false,[b]"profile_link_color":"CC3366","id_str":"325679866"[/b],"url":null,"favourites_count":3,"default_profile":false,"contributors_enabled":false,"states":{"bouncing_email":false,"pending_email":false,"detached_email":false,"suspended":false,"needs_employee_email_update":false},"id":325679866,"utc_offset":-18000,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1440208978\/jquery_normal.jpeg","profile_use_background_image":true,"listed_count":0,"lang":"ru","followers_count":9,"protected":false,"profile_text_color":"333333","geo_enabled":true,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme17\/bg.gif","time_zone":"Quito","notifications":false,"verified":false,"profile_background_color":"DBE9ED","description":"\u0413\u043d\u0443\u0441\u043d\u044b\u0439 \u0441\u043e\u0446\u0438\u043e\u043f\u0430\u0442 \u0441 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043e\u043c \u0411\u043e\u0433\u0430","friends_count":24,"statuses_count":63,"default_profile_image":false,"status":{"coordinates":null,"truncated":false,"favorited":false,"created_at":"Wed Oct 26 11:22:17 +0000 2011","retweeted_status":{"coordinates":null,"truncated":false,"favorited":false,"created_at":"Tue Oct 25 19:11:35 +0000 2011","id_str":"128911601653923840","entities":{"urls":[],"hashtags":[],"user_mentions":[]},"in_reply_to_user_id_str":null,"text":"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b - \u043e\u0447\u0435\u043d\u044c \u0434\u0443\u0448\u0435\u0432\u043d\u044b\u0435 \u043b\u044e\u0434\u0438. \u041f\u043e \u0432\u0435\u0447\u0435\u0440\u0430\u043c \u043e\u043d\u0438 \u0441\u0430\u0434\u044f\u0442\u0441\u044f \u0432 \u043a\u0440\u0435\u0441\u043b\u043e, \u043d\u0430\u043b\u0438\u0432\u0430\u044e\u0442 \u0441\u0435\u0431\u0435 \u0447\u0430\u044e \u0438 \u0441\u043c\u043e\u0442\u0440\u044f\u0442, \u043a\u0430\u043a \u0433\u043e\u0440\u044f\u0442 \u0441\u0440\u043e\u043a\u0438 \u0441\u0434\u0430\u0447\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432...",

Спустя 10 минут, 58 секунд (1.11.2011 - 13:19) Winston написал(а):
Тебе, что только id_str нужно достать ?
preg_match_all('#id_str":"(\d{7,})#', $str, $match);
print_r($match);

Говори, что нужно достать из JS кода &

Спустя 3 минуты, 54 секунды (1.11.2011 - 13:23) RCuPeR написал(а):
Понимаешь, этих id_str во всем JS коде дохрена. Я скинул тебе кусочек JS.
Нужно достать id_str отсюда:
$str = '"profile_link_color":"значение из 6-и символов","id_str":"325679866"';

Это самый рациональный вариант.

Спустя 3 минуты, 13 секунд (1.11.2011 - 13:26) Winston написал(а):
Ну если только id_str достать нужно, то так
preg_match_all('#"id_str":"(\d+)"#isU', $str, $match);
print_r($match);

Спустя 8 минут, 2 секунды (1.11.2011 - 13:35) RCuPeR написал(а):
Если быть точнее, то так:

$str = '"profile_link_color":"CC3366","id_str":"325679866"';
$pattern = '#"profile_link_color":"CC3366","id_str":"(\d+)"#isU';

preg_match_all($pattern, $str, $match);
print_r($match);


Можешь подсказать, как дать знать паттерну, что внутри кавычек "CC3366" будет не CC3366, а 6 символов ?

Спустя 2 минуты, 10 секунд (1.11.2011 - 13:37) Winston написал(а):
Если только символов, то
#"profile_link_color":"[a-z]{6}","id_str":"(\d+)"#isU

Если символы и цифры, то
#"profile_link_color":"[a-f\d]{6}","id_str":"(\d+)"#isU

Спустя 9 минут, 7 секунд (1.11.2011 - 13:46) sharki написал(а):
$l = "{";
$r = "}";

$str = '"profile_link_color":"CC3366","id_str":"325679866"';
$arr = json_decode($l.$str.$r, true);

echo $arr['id_str']; // 325679866

Спустя 3 минуты, 21 секунда (1.11.2011 - 13:49) RCuPeR написал(а):
Да, скорей второй вариант. Спасибо, этот вопрос решен.
Но я еще вернусь rolleyes.gif



Спустя 1 минута, 47 секунд RCuPeR написал(а):
Цитата (sharki @ 1.11.2011 - 10:46)
$l = "{";
$r = "}";

$str = '"profile_link_color":"CC3366","id_str":"325679866"';
$arr = json_decode($l.$str.$r, true);

echo $arr['id_str']; // 325679866

Не-не-не. Тут не та ситуацьен, долго объяснять. Спасибо за внимание, но это не поможет, нужно только регуляркой.


_____________
Гнусный социопат с комплексом Бога.
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.